r

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.

Can't Calculate pixel-wise regression in R on raster stack with fun

天大地大妈咪最大 提交于 2021-02-10 11:48:12
问题 I am working with rasters and I've a RasterStack with 7n layers. I would like to calculate pixel-wise regression, using formula beneath. I was trying to do it with raster::calc , but my function failed with message : 'Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases.' But all rasters are OK, and contain numbers (not only NAs), I can plot it, and I can calculate general linear regression with formula cr.sig=lm (raster::as.array(MK_trend.EVI.sig_Only) ~

Solve system of non-linear equations

ε祈祈猫儿з 提交于 2021-02-10 10:54:30
问题 I am trying to solve the following system of four equations. I have tried using the "rootSolve" package but it does not seem like I can find a solution this way. The code I am using is the following: model <- function(x) { F1 <- sqrt(x[1]^2 + x[3]^2) -1 F2 <- sqrt(x[2]^2 + x[4]^2) -1 F3 <- x[1]*x[2] + x[3]*x[4] F4 <- -0.58*x[2] - 0.19*x[3] c(F1 = F1, F2 = F2, F3 = F3, F4 = F4) } (ss <- multiroot(f = model, start = c(0,0,0,0))) But it gives me the following error: Warning messages: 1: In stode

R ifelse is erroneously replacing text with integers

佐手、 提交于 2021-02-10 10:45:17
问题 I have some data that I'm working with from a Udacity course (Link: Reddit Survey Responses). I'm trying to simplify the Employment Status variable by replacing any multi-word values with single word alternates using RS$employment.status <- ifelse(RS$employment.status == "Not employed, but looking for work", "Unemployed", RS$employment.status) However, when I run the code any values that aren't supposed to be replaced are replaced with numeric values. Given that the else case is to use the

R ifelse is erroneously replacing text with integers

若如初见. 提交于 2021-02-10 10:44:35
问题 I have some data that I'm working with from a Udacity course (Link: Reddit Survey Responses). I'm trying to simplify the Employment Status variable by replacing any multi-word values with single word alternates using RS$employment.status <- ifelse(RS$employment.status == "Not employed, but looking for work", "Unemployed", RS$employment.status) However, when I run the code any values that aren't supposed to be replaced are replaced with numeric values. Given that the else case is to use the

R ifelse is erroneously replacing text with integers

拟墨画扇 提交于 2021-02-10 10:43:01
问题 I have some data that I'm working with from a Udacity course (Link: Reddit Survey Responses). I'm trying to simplify the Employment Status variable by replacing any multi-word values with single word alternates using RS$employment.status <- ifelse(RS$employment.status == "Not employed, but looking for work", "Unemployed", RS$employment.status) However, when I run the code any values that aren't supposed to be replaced are replaced with numeric values. Given that the else case is to use the

Custom Performance Function in caret Package using predicted Probability

独自空忆成欢 提交于 2021-02-10 10:40:48
问题 This SO post is about using a custom performance measurement function in the caret package. You want to find the best prediction model, so you build several and compare them by calculating a single metric that is drawn from comparing the observation and the predicted value. There are default functions to calculate this metric, but you can also define your own metric-function. This custom functions must take obs and predicted values as input. In classification problems (let's say only two

How to write model file for JAGS binomial using logit function

泪湿孤枕 提交于 2021-02-10 10:14:17
问题 I am working on an assignment using JAGS to model a binomial distribution who's p parameter is a function of another variable d . This is what I am trying to do: generate 10000 samples from the posterior for the two parameters alpha/beta produce samples to from the posterior predicted number of success when dist = 25 for 100 attempts calculate 95 credible interval for success rate at 25 feet distance I have written the model but it is giving an error. Below is the code I have already tried #R

How to write model file for JAGS binomial using logit function

情到浓时终转凉″ 提交于 2021-02-10 10:12:33
问题 I am working on an assignment using JAGS to model a binomial distribution who's p parameter is a function of another variable d . This is what I am trying to do: generate 10000 samples from the posterior for the two parameters alpha/beta produce samples to from the posterior predicted number of success when dist = 25 for 100 attempts calculate 95 credible interval for success rate at 25 feet distance I have written the model but it is giving an error. Below is the code I have already tried #R