beta_coefficients
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| beta_coefficients [2020/12/09 09:34] – [e.g.] hkimscil | beta_coefficients [2026/06/14 23:44] (current) – hkimscil | ||
|---|---|---|---|
| Line 9: | Line 9: | ||
| < | < | ||
| # import test score data " | # import test score data " | ||
| - | tests <- read.csv(" | + | tests <- read.csv(" |
| colnames(tests) <- c(" | colnames(tests) <- c(" | ||
| tests <- subset(tests, | tests <- subset(tests, | ||
| Line 88: | Line 88: | ||
| < | < | ||
| # get marketing data | # get marketing data | ||
| - | marketing <- read.csv(" | + | marketing <- read.csv(" |
| head(marketing) | head(marketing) | ||
| # note that I need - X to get rid of X column in the marketing data | # note that I need - X to get rid of X column in the marketing data | ||
| Line 96: | Line 96: | ||
| < | < | ||
| - | > marketing <- read.csv(" | + | > marketing <- read.csv(" |
| > head(marketing) | > head(marketing) | ||
| X youtube facebook newspaper sales | X youtube facebook newspaper sales | ||
| Line 149: | Line 149: | ||
| > | > | ||
| </ | </ | ||
| + | |||
| + | These beta coefficients also can be got from the coefficents from standardized data. | ||
| + | |||
| + | < | ||
| + | mod.formula <- sales ~ youtube + facebook + newspaper | ||
| + | all.vars(mod.formula) | ||
| + | marketing.temp <- sapply(marketing[ , all.vars(mod.formula)], | ||
| + | head(marketing.temp) | ||
| + | mod.scaled <- lm(sales ~ ., data=marketing.scaled) | ||
| + | head(marketing.scaled) | ||
| + | coefficients(mod.scaled) | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | > all.vars(mod.formula) | ||
| + | [1] " | ||
| + | > marketing.temp <- sapply(marketing[ , all.vars(mod.formula)], | ||
| + | > head(marketing.temp) | ||
| + | sales | ||
| + | [1,] 1.5481681 | ||
| + | [2,] -0.6943038 -1.19437904 | ||
| + | [3,] -0.9051345 -1.51235985 | ||
| + | [4,] 0.8581768 | ||
| + | [5,] -0.2151431 | ||
| + | [6,] -1.3076295 -1.61136487 | ||
| + | > mod.scaled <- lm(sales ~ ., data=marketing.scaled) | ||
| + | > head(marketing.scaled) | ||
| + | | ||
| + | 1 1.5481681 | ||
| + | 2 -0.6943038 -1.19437904 | ||
| + | 3 -0.9051345 -1.51235985 | ||
| + | 4 0.8581768 | ||
| + | 5 -0.2151431 | ||
| + | 6 -1.3076295 -1.61136487 | ||
| + | > coefficients(mod.scaled) | ||
| + | (Intercept) | ||
| + | -5.034110e-16 | ||
| + | > | ||
| + | > </ | ||
| + | |||
| + | check out that | ||
| + | '' | ||
| + | |||
| + | and | ||
| + | 베타를 구하고 나면 서로의 계수값을 절대비교할 수 있다. | ||
| + | '' | ||
| + | '' | ||
| + | |||
beta_coefficients.1607506444.txt.gz · Last modified: by hkimscil
