r:multiple_regression
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
r:multiple_regression [2019/11/08 09:26] – [Partial, Semi-partial Correlation and R squared value] hkimscil | r:multiple_regression [2020/08/31 12:31] – hkimscil | ||
---|---|---|---|
Line 253: | Line 253: | ||
coefficients(lm.stock) | coefficients(lm.stock) | ||
</ | </ | ||
+ | |||
+ | < | ||
+ | [1] " | ||
+ | [6] " | ||
+ | [11] " | ||
+ | |||
< | < | ||
Line 404: | Line 410: | ||
이 둘의 합은 '' | 이 둘의 합은 '' | ||
- | {{20191108_092352.jpg}} | + | {{20191108_092352.jpg?400}} |
Line 512: | Line 518: | ||
</ | </ | ||
+ | Alternatively, | ||
+ | |||
+ | < | ||
+ | > install.packages(" | ||
+ | > library(lmtest) | ||
+ | > lrtest(lm.stock.int, | ||
+ | Likelihood ratio test | ||
+ | |||
+ | Model 1: Stock_Index_Price ~ Interest_Rate | ||
+ | Model 2: Stock_Index_Price ~ Interest_Rate + Unemployment_Rate | ||
+ | #Df LogLik Df Chisq Pr(> | ||
+ | 1 3 -136.94 | ||
+ | 2 4 -134.61 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > </ | ||
+ | ====== e.g. 5 ====== | ||
+ | < | ||
+ | #packages we will need to conduct to create and graph our data | ||
+ | library(MASS) #create data | ||
+ | library(car) #graph data | ||
+ | py1 =.6 #Cor between X1 (Practice Time) and Memory Errors | ||
+ | py2 =.4 #Cor between X2 (Performance Anxiety) and Memory Errors | ||
+ | p12= .3 #Cor between X1 (Practice Time) and X2 (Performance Anxiety) | ||
+ | Means.X1X2Y< | ||
+ | CovMatrix.X1X2Y <- matrix(c(1, | ||
+ | p12,1,py2, | ||
+ | py1, | ||
+ | #build the correlated variables. Note: empirical=TRUE means make the correlation EXACTLY r. | ||
+ | # if we say empirical=FALSE, | ||
+ | set.seed(42) | ||
+ | CorrDataT< | ||
+ | #Convert them to a " | ||
+ | CorrDataT< | ||
+ | colnames(CorrDataT) <- c(" | ||
+ | #make the scatter plots | ||
+ | scatterplot(Memory~Practice, | ||
+ | scatterplot(Memory~Anxiety, | ||
+ | scatterplot(Anxiety~Practice, | ||
+ | # Pearson Correlations | ||
+ | ry1< | ||
+ | ry2< | ||
+ | r12< | ||
+ | </ | ||
r/multiple_regression.txt · Last modified: 2023/10/19 08:23 by hkimscil