please show the steps and the code to solve this in R, thank you
i) R code to estimate the model (all statements starting with # are comments and can be removed)
#Load the data hprice1
data(hprice1,package='wooldridge')
#print some records
head(hprice1)
#estimate the regression equation
fit<-lm(price~bdrms+sqrft+lotsize,data=hprice1)
summary(fit)
#get this
The estimated model is
The estimated value of the slope coefficient for bdrms is 13.8525
This indicates that when the value of bdrms increase by 1, the price of the house increases by 13.8525 (in thousands of dollars), while holding sqrft and lotsize constant.
ans: The estimated increase in price for a house with one more bedroom, holding square footage and lot size constant is $13,852.5
iii) The estimated increase in price for one more bedroom is $13,852.5 from part ii).
The slope coefficient of sqrft is 0.1228. This indicates that for 1 square foot increase the price would increase by $0.1228 (thousands of dollars). The increase in the price for 140 square feet increase in the house area is 0.1228*140 = 17.1889 (in thousands of dollars)
The model is an additive. That means we can just add up the change in price due to increase in the number of bedrooms by 1 and due to which the increase in the total square feet by 140
ans: The estimated increase in price for a house with an additional bedroom of 140 square feet in size holding lot size constant is 13,852.5+17,188.9=31041.5
In ii) we calculate the increase in price due to addition of 1 bedroom, while keeping the square foot of the house and the lot size the same, where as in iii) the price increase is due to an addition of 1 bedroom of size 140 square feet, due to which the total square feet increased by 140, while holding only the lot size the same.
iv) The value of r-square is (from the output)
This indicates that 67.24% of variation in price is explained by square footage, lot size and number of bedrooms
v) The predicted selling price is
ans: The predicted selling price is $345,639.8
R code
#predicted selling price
sp<-fit$coef[1]+fit$coef[2]*4+fit$coef[3]*2438+fit$coef[4]*6126
sprintf('The predicted selling price is $%.1f',sp*1000)
#or use this
sp<-predict(fit,newdata=data.frame(bdrms=4,sqrft=2438,lotsize=6126))
sprintf('The predicted selling price is $%.1f',sp*1000)
# get this
vi) The fitted values for the data are stored in the variable fit$fitted.values.
The residual is actual - fitted value
R code
#calculate the residual for the first house in the sample
res<-300-fit$fitted.values[1]
sprintf('The residual for the first house in the sample is
%.4f',res)
# get this
The residuals are also directly stored in fit$residuals
R code
res<-fit$residuals[1]
sprintf('The residual for the first house in the sample is
%.4f',res)
# get this
The residual is negative. This indicates that the predicted price is higher than the actual price, that means the buyer has paid less than the price predicted by the model.
ans: The buyer has underpaid for the house.
please show the steps and the code to solve this in R, thank you 11. (10 marks) (using dataset: "hpricel", in R:...
Using the package “wooldridge’, and the data ‘hprice1’ (in R-Software) to estimate the model price = β0 + β1sqrft + β2bdrms + u , where is the house price measured in thousands of dollars. 1. Write out the results in equation form. 2. What is the estimated increase in price for a house with one more bedroom, holding square footage constant? 3. What is the estimated increase in price for a house with an additional bedroom that is 140 square feet...
2. Use the data in hpricel.wfl uploaded on Moodle for this exercise. We assume that all assump- tions of the Classical Linear Model are satisfied for the model used in this question. (a) Estimate the model and report the results in the usual form, including the standard error of the regression. Obtain the predicted price when we plug in lotsize - 10, 000, sqrft - 2,300, and bdrms- 4; round this price to the nearest dollar. (b) Run a regression...
IL. (1Ipts) You are given the following estimated equation: log(price) =-0.676 + 0.848 log(sqrft)-0.05 1bdrrns-0.269colonial + 0.098bdrms * colonial Std. Errors (0.693) (0.1003) (0.060) n 88, R-squared -0.5793 (0.216) (0.0636) Where the variables are described as follows: price sarfi the size of the house, in squared feet hdrms the number of bedrooms in the house colonial- if the house has a colonial architectural style, and 0 otherwise. bdrms colonial interaction variable the house price, in $1000 a. Provide an appropriate...
II. (11pts) You are given the following estimated equation: log(price) 4.83+0.000347sqrft + 0.0117bdrms-0.056colonial +0.000068srft colonial Std. Errors (0.013) (0.000061) (0.0310) (0.015) (0.000074) n 88, R-square -0.6056 e tri Where the variables are described as follows: price = the house price, in $1000 sar-the size of the house, in squared feet bdrms the number of bedrooms in the house colonial- 1 if the house has a colonial architectural style, and 0 otherwise. sarfi colonial interaction variable Sser a. Provide an appropriate...
I need to know the code to do this question in R thanks 10. (8 marks) (using dataset: "meap93", in R: data(meap93, package-'wooldridge)) We want to explore the relationship between the math pass rate (scil/) and average teachers' compensation (salary + benefits) in the school (totcomp) In the population model: scill,-β0 + βι log(totcompi-u, prove that β/ 10 is the percentage point change in scill given a 10% increase in totcom. ii Use the data in MEAP93 to estimate the...
what is R^2 Question Help a random sample of 250 home sales from a community in 2003. Let Price denote the selling price (in $1,000), BDR denote the number of bedrooms, Bath denote the number of bathrooms, Hsize denote the size of the house (in square feet), Lsize denote the lot size (in square the house (in years), and Poor denote a binary variable that is equal to 1 if the condition of the house is reported as "poor An...
Data were collected from a random sample of 220 home sales from a community. Let Price denote the selling price (in $1000), BDR denote the number of bedrooms, Bath denote the number of bathrooms, Hsize denote the size of the house (in square feet), Lsize denote the lot size (in square feet), Age denote the age of the house (in years), and Poor denote a binary variable that is equal to 1 if the condition of the house is reported...