lm

Manually bootstrapping linear regression in R

早过忘川 提交于 2021-02-10 11:53:05
问题 |Hi guys, I am asking you for help as I am stucked with bootstrapping... The task is: Use the nonparametric bootstrap to compute bootstrap standard error of CAPM beta estimate based on 1000 bootstrap replications and bootstrap sample size equal to the size of the original sample. If I understand it correctly, I am supposed to run my regression model 1000 times to estimate different estimates of the beta and its standard error. However, I am not able to put my thoughts into an actual R code.

Manually bootstrapping linear regression in R

匆匆过客 提交于 2021-02-10 11:49:14
问题 |Hi guys, I am asking you for help as I am stucked with bootstrapping... The task is: Use the nonparametric bootstrap to compute bootstrap standard error of CAPM beta estimate based on 1000 bootstrap replications and bootstrap sample size equal to the size of the original sample. If I understand it correctly, I am supposed to run my regression model 1000 times to estimate different estimates of the beta and its standard error. However, I am not able to put my thoughts into an actual R code.

Manually bootstrapping linear regression in R

十年热恋 提交于 2021-02-10 11:49:11
问题 |Hi guys, I am asking you for help as I am stucked with bootstrapping... The task is: Use the nonparametric bootstrap to compute bootstrap standard error of CAPM beta estimate based on 1000 bootstrap replications and bootstrap sample size equal to the size of the original sample. If I understand it correctly, I am supposed to run my regression model 1000 times to estimate different estimates of the beta and its standard error. However, I am not able to put my thoughts into an actual R code.

Write a function to list all possible combinations of models

邮差的信 提交于 2021-02-08 11:59:49
问题 I'm attempting to write a function to run all possible regression models for variables in a dataset. I was able to get it to run each variable, this is what I have so far. library(tidyverse) library(broom) data("mtcars") model1 <- function (DATA) { DATA %>% map(~lm(mpg ~ .x, data = DATA), tidy)%>% map(summary) %>% map_dbl("adj.r.squared") %>% tidy %>% rename(adj.r.squared = x) } model1(mtcars) I am new to R and writing functions so I am sure there are some issues with it. I want a tibble of

How to add annotation over line plot to mark percent change in y-values between discrete x-values

房东的猫 提交于 2021-02-08 10:38:28
问题 I want to visualize the results of a linear model where dependent variable values change as a function of discrete x-values. Since my x-values represent consecutive days, I want to annotate the change from day to day, in percents. How can I do this in a line plot? My Data I want to measure people's mood. Every day I collect responses from 1000 different people on how they feel. I therefore get a daily average for mood, and I want to see how it changes from one day to another. library

How to add annotation over line plot to mark percent change in y-values between discrete x-values

狂风中的少年 提交于 2021-02-08 10:36:14
问题 I want to visualize the results of a linear model where dependent variable values change as a function of discrete x-values. Since my x-values represent consecutive days, I want to annotate the change from day to day, in percents. How can I do this in a line plot? My Data I want to measure people's mood. Every day I collect responses from 1000 different people on how they feel. I therefore get a daily average for mood, and I want to see how it changes from one day to another. library

Many regressions using tidyverse and broom: Same dependent variable, different independent variables

风格不统一 提交于 2021-02-08 04:50:44
问题 This link shows how to answer my question in the case where we have the same independent variables, but potentially many different dependent variables: Use broom and tidyverse to run regressions on different dependent variables. But my question is, how can I apply the same approach (e.g., tidyverse and broom) to run many regressions where we have the reverse situation: same dependent variables but different independent variable. In line with the code in the previous link, something like: mod

Many regressions using tidyverse and broom: Same dependent variable, different independent variables

佐手、 提交于 2021-02-08 04:49:40
问题 This link shows how to answer my question in the case where we have the same independent variables, but potentially many different dependent variables: Use broom and tidyverse to run regressions on different dependent variables. But my question is, how can I apply the same approach (e.g., tidyverse and broom) to run many regressions where we have the reverse situation: same dependent variables but different independent variable. In line with the code in the previous link, something like: mod

Many regressions using tidyverse and broom: Same dependent variable, different independent variables

ぐ巨炮叔叔 提交于 2021-02-08 04:49:33
问题 This link shows how to answer my question in the case where we have the same independent variables, but potentially many different dependent variables: Use broom and tidyverse to run regressions on different dependent variables. But my question is, how can I apply the same approach (e.g., tidyverse and broom) to run many regressions where we have the reverse situation: same dependent variables but different independent variable. In line with the code in the previous link, something like: mod

How can I calculate the slope of multiple subsets of a data frame more efficiently? [duplicate]

对着背影说爱祢 提交于 2021-02-07 20:58:08
问题 This question already has answers here : Linear Regression and group by in R (10 answers) Closed 4 years ago . I have a data set that contains the optical absorption ( a ) across a range of wavelengths ( wl ) for 16 different samples ( bod ) on 5 different days ( day ). The dput output for samples ( bod ) 1 - 3 is below. I need the slope of the natural log of the absorption by wavelength for each sample on each day. My current approach has been to do this manually: # calculate and extract the