Question
r code for, any dataset will y, x1 and x2 will be okay
3- Refer to Brand preference data and problem in Assignment 5 (30 pts) a) Transform the variables by means of the correlation
0 0
Add a comment Improve this question Transcribed image text
Answer #1
### Sample Data
x1 <- c(2.75,2.5,2.5,2.5,2.5,2.5,2.5,2.25,2.25,2.25,2,2,2,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75,1.75)
x2 <- c(5.3,5.3,5.3,5.3,5.4,5.6,5.5,5.5,5.5,5.6,5.7,5.9,6,5.9,5.8,6.1,6.2,6.1,6.1,6.1,5.9,6.2,6.2,6.1)
y <- c(1464,1394,1357,1293,1256,1254,1234,1195,1159,1167,1130,1075,1047,965,943,958,971,949,884,866,876,822,704,719) 

#check for linearity
# With x1
plot(x=x1, y=y) 
## with x2
plot(x=x2, y=y) 

### correlation of variable

cor.test( ~ y + x1,
          method = "pearson")

cor.test( ~ y + x2,
          method = "pearson")

### Linear Regression with Two variable (using transformation )
model <- lm(log(1+y) ~ x1 + x2)
summary(model)

## Residul Comparision 
x = residuals(model)
library(rcompanion)

plotNormalHistogram(x)
Add a comment
Know the answer?
Add Answer to:
r code for, any dataset will y, x1 and x2 will be okay 3- Refer to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer the following question by showing the codes in R 2. Consider the dataset mtcars and...

    Answer the following question by showing the codes in R 2. Consider the dataset mtcars and suppose we are interested in modeling the mpg of a vehicle based on a single variable presented in the dataset. a) Use the cor ) function in R, apply it to only numerical variables in the dataset. Identify the numerical variable that shows the most significant correlation, and generate a scatterplot between this variable and mpg. b) Use the 1m() function in R to...

  • I. In a regression analysis of banks, four types of banks were involved, namely, commercial banks,...

    I. In a regression analysis of banks, four types of banks were involved, namely, commercial banks, mutual banks, community banks and savings banks. In this study, Y is the previous year's profit (in millions of dollars), X, is the size of the bank (in millions of dollars) and type of bank = X, X, X, which are indicator variables as coded below. Type of Bank X X X , Commercial 1 0 Mutual Community Savings 0 0 0 The first-order...

  • The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the...

    The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models). The data frame has 32 observation on 11 (numeric) variables: mpg: Miles/(US) gallon; cyl: Number of cylinders; disp: Displacement (cu.in.); hp: Gross horsepower; drat: Rear axle ratio; wt: Weight (1000 lbs); qsec: 1/4 mile time; vs: Engine (0 = V-shaped, 1 =...

  • gold ($/oz) Y copper (cents/lb) X1 silver ($/oz) X2 Aluminum (cents/lb) X3 161.1 64.2 4.4 39.8...

    gold ($/oz) Y copper (cents/lb) X1 silver ($/oz) X2 Aluminum (cents/lb) X3 161.1 64.2 4.4 39.8 308 93.3 11.1 61 613 101.3 20.6 71.6 460 84.2 10.5 76 376 72.8 8 76 424 76.5 11.4 77.8 361 66.8 8.1 81 318 67 6.1 81 368 66.1 5.5 81 448 82.5 7 72.3 438 120.5 6.5 110.1 382.6 130.9 5.5 87.8 Statistics 11 Homework 9 Due Wednesday, Nov. 20 Metals.jmp lists the yearly average price of gold, copper, silver, and aluminum....

  • please help with step by step calculations Variables Entered/Removed Variables Removed Model Variables Entered) Method contraception...

    please help with step by step calculations Variables Entered/Removed Variables Removed Model Variables Entered) Method contraception use (%) Enter a. All requested variables entered. b. Dependent Variable: fertility rate per woman Model Summary Std. Error of the Estimate Model R .71764 Adjusted R2 Square .469 220 168 a. Predictors: (Constant), contraception use %) ANOVA Model Sum of Squares Idf Regression 2.177 Residual 7.725 Total 9.902 Mean Square 2.177 .515 a. Predictors: (Constant), contraception use (%) b. Dependent Variable: fertility rate...

  • data set Nicotine (Y) Tar (X1) CO (X2) 0.8 13 18 0.8 13 18 0.2 1...

    data set Nicotine (Y) Tar (X1) CO (X2) 0.8 13 18 0.8 13 18 0.2 1 2 1.1 18 17 1 16 18 1.1 15 18 1.2 15 14 1.1 15 15 0.9 14 15 0.9 14 14 QUESTIONS 9 point The accompanying table, MultiLinear Regression 4, provides data for tar, nicotine, and carbon monoxide (Cco) contents in a certain brand of cigarette. All measurements are in milligrams (mg). Part a) Run the Multilinear Regression Analysis in Excel with both...

  • USE R STUDIO The stackloss data frame available in R contains 21 observations on four variables...

    USE R STUDIO The stackloss data frame available in R contains 21 observations on four variables taken at a factory where ammonia is converted to nitric acid. The first three variables are Air.Flow, Water.Temp, and Acid.Conc. The fourth variable is stack.loss, which measures the amount of ammonia that escapes before being absorbed. Read the help file for more information about this data frame. - Give a numerical summarization of each column of the dataset, then use boxplots to help illustrating...

  • Need help with stats true or false questions Decide (with short explanations) whether the following statements are true or false a) We consider the model y-Ao +A(z) +E. Let (-0.01, 1.5) be a 95% con...

    Need help with stats true or false questions Decide (with short explanations) whether the following statements are true or false a) We consider the model y-Ao +A(z) +E. Let (-0.01, 1.5) be a 95% confidence interval for A In this case, a t-test with significance level 1% rejects the null hypothesis Ho : A-0 against a two sided alternative. b) Complicated models with a lot of parameters are better for prediction then simple models with just a few parameters c)...

  • 1. Choose a data set of your own:?Response or dependent variable (Y)?At least 3 or more...

    1. Choose a data set of your own:?Response or dependent variable (Y)?At least 3 or more independent variables (X1, X2, X3, ... etc.) that you believe has an influence on Y.?At least 40 observations or data points?If there are categorical variables, model them appropriately2. Fit a multiple regression model. ?Interpret the model equation?Are all the chosen variables significant? Discuss.?Check for model assumptions and make appropriate comments.?How good is the model? Comment on R2 , R , se, F-value etc and...

  • all data is built in in R 4. For Questions 4-11, use the swiss dataset, which is built into R. Fit a multiple linear re...

    all data is built in in R 4. For Questions 4-11, use the swiss dataset, which is built into R. Fit a multiple linear regression model with Fertility as the response and the remaining variables as predictors. You should use ?swiss to learn about the background of this dataset 1 Run Reset Use your fitted model to make a prediction for a Swiss province in 1888 with: 54% of males involved in agriculture as occupation 23% of draftees receiving highest...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT