-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase Housing Econometrics SAS Code.sas
248 lines (183 loc) · 4.02 KB
/
Base Housing Econometrics SAS Code.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*William-Elijah Clark wec19b STA 3064 Project A Code*/
/** FOR CSV Files uploaded from Windows **/
FILENAME CSV "/home/u49665201/sasuser.v94/STA3064/Copy 2 of FY2021_50_County.csv" TERMSTR=CRLF;
/** Import the CSV file. **/
PROC IMPORT DATAFILE=CSV
OUT=HUDdata
DBMS=CSV
REPLACE;
RUN;
/** Print the results. **/
PROC PRINT DATA=HUDdata; RUN;
/*****************************************/
/*Simple Linear Regression Model Attempts*/
/*****************************************/
proc reg data=HUDdata;
model rent50_0=pop2017;
run;
proc reg data=HUDdata;
model rent50_1=pop2017;
run;
proc reg data=HUDdata;
model rent50_2=pop2017;
run;
proc reg data=HUDdata;
model rent50_3=pop2017;
run;
proc reg data=HUDdata;
model rent50_4=pop2017;
run;
proc reg data=HUDdata;
model rent50_0=hu2017;
run;
proc reg data=HUDdata;
model rent50_1=hu2017;
run;
proc reg data=HUDdata;
model rent50_2=hu2017;
run;
proc reg data=HUDdata;
model rent50_3=hu2017;
run;
proc reg data=HUDdata;
model rent50_4=hu2017;
run;
/*Setting up more variables to try*/
data Housing;
set HUDdata;
PtoH = pop2017/hu2017;
HtoP = hu2017/pop2017;
transPop = pop2017**-1;
transHu = hu2017**-1;
run;
/*Note: PtoH is a ratio of the population of an area to housing units in an area, while HtoP is number of housing units per person
in an area. My hunch is that HtoP would be a better metric, but I don't actually know which will be better (or if it even makes a
notable difference, for that matter). It doesn't fit the standard concept of price elasticity in economics, but it could be used to account
for population density*/
proc reg data=Housing;
model rent50_0=PtoH;
run;
proc reg data=Housing;
model rent50_1=PtoH;
run;
proc reg data=Housing;
model rent50_2=PtoH;
run;
proc reg data=Housing;
model rent50_3=PtoH;
run;
proc reg data=Housing;
model rent50_4=PtoH;
run;
proc reg data=Housing;
model rent50_0=HtoP;
run;
proc reg data=Housing;
model rent50_1=HtoP;
run;
proc reg data=Housing;
model rent50_2=HtoP;
run;
proc reg data=Housing;
model rent50_3=HtoP;
run;
proc reg data=Housing;
model rent50_4=HtoP;
run;
/*Models with Box-Cox transformations*/
proc transreg data=Housing;
model boxcox(rent50_2)=identity(HtoP);
run;
proc transreg data=Housing;
model boxcox(rent50_2)=identity(PtoH);
run;
proc transreg data=HUDdata;
model boxcox(rent50_2)=identity(pop2017);
run;
proc transreg data=HUDdata;
model boxcox(rent50_2)=identity(hu2017);
run;
/*Hmm. All of these suggest a transform of -0.75, so...let's go back up and add that transformation into the data...*/
proc reg data=Housing;
model rent50_0=transPop;
run;
proc reg data=Housing;
model rent50_1=transPop;
run;
proc reg data=Housing;
model rent50_2=transPop;
run;
proc reg data=Housing;
model rent50_3=transPop;
run;
proc reg data=Housing;
model rent50_4=transPop;
run;
proc reg data=Housing;
model rent50_0=transHu;
run;
proc reg data=Housing;
model rent50_1=transHu;
run;
proc reg data=Housing;
model rent50_2=transHu;
run;
proc reg data=Housing;
model rent50_3=transHu;
run;
proc reg data=Housing;
model rent50_4=transHu;
run;
/***************/
/*Scatter plots*/
/***************/
proc sgplot data=Housing;
scatter X=rent50_2 Y=pop2017;
run;
proc sgplot data=Housing;
scatter X=rent50_2 Y=hu2017;
run;
proc sgplot data=Housing;
scatter X=rent50_2 Y=HtoP;
run;
proc sgplot data=Housing;
scatter X=rent50_2 Y=PtoH;
run;
proc sgplot data=Housing;
scatter X=rent50_2 Y=transHu;
run;
proc sgplot data=Housing;
scatter X=rent50_2 Y=transPop;
run;
/**************/
/*LOESS Models*/
/**************/
proc loess data=Housing;
model pop2017=rent50_2;
run;
proc loess data=Housing;
model pop2017=rent50_2;
run;
proc loess data=Housing;
model pop2017=HtoP;
run;
proc loess data=Housing;
model pop2017=PtoH;
run;
proc loess data=Housing;
model transPop=rent50_2;
run;
proc loess data=Housing;
model transHu=rent50_2;
run;
/**************/
/*ANOVA Models*/
/**************/
proc ANOVA data=Housing;
class hu2017;
model rent50_2=hu2017;
run;
proc ANOVA data=Housing;
class PtoH;
model rent50_2=PtoH;
run;