lm

How to debug “contrasts can be applied only to factors with 2 or more levels” error?

偶尔善良 提交于 2020-01-07 08:02:07
问题 Here are all the variables I'm working with: str(ad.train) $ Date : Factor w/ 427 levels "2012-03-24","2012-03-29",..: 4 7 12 14 19 21 24 29 31 34 ... $ Team : Factor w/ 18 levels "Adelaide","Brisbane Lions",..: 1 1 1 1 1 1 1 1 1 1 ... $ Season : int 2012 2012 2012 2012 2012 2012 2012 2012 2012 2012 ... $ Round : Factor w/ 28 levels "EF","GF","PF",..: 5 16 21 22 23 24 25 26 27 6 ... $ Score : int 137 82 84 96 110 99 122 124 49 111 ... $ Margin : int 69 18 -56 46 19 5 50 69 -26 29 ... $

/cs/software/anaconda3/compiler_compat/ld: cannot find -lm cannot find -lpthread cannot find -lc

老子叫甜甜 提交于 2020-01-07 04:00:57
问题 How should I fix this error in CentOS 7? [jalal@goku HW4]$ git clone https://github.com/pathak22/pyflow.git Cloning into 'pyflow'... remote: Counting objects: 96, done. remote: Total 96 (delta 0), reused 0 (delta 0), pack-reused 96 Unpacking objects: 100% (96/96), done. [jalal@goku HW4]$ ls pyflow [jalal@goku HW4]$ cd pyflow/ [jalal@goku pyflow]$ ls LICENSE README.md demo.py examples pyflow.pyx setup.py src [jalal@goku pyflow]$ python demo.py Traceback (most recent call last): File "demo.py",

regarding the failure of stepwise variable selection in lm

爱⌒轻易说出口 提交于 2020-01-06 17:29:45
问题 I built a regression model using all the variables at first. full.model<-lm(y~as.matrix(x)) Then I tried to use step-wise variable selection reduce.model<-step(full.model,direction="backward") The running result is shown as follows, looks like it does not do anything. What is the problem of this scenario. I also include the detail of full.model in the following. > reduce.model<-step(full.model,direction="backward") Start: AIC=-121.19 y ~ as.matrix(x) Df Sum of Sq RSS AIC <none> 1.1 -121.19 -

regarding the failure of stepwise variable selection in lm

牧云@^-^@ 提交于 2020-01-06 17:28:31
问题 I built a regression model using all the variables at first. full.model<-lm(y~as.matrix(x)) Then I tried to use step-wise variable selection reduce.model<-step(full.model,direction="backward") The running result is shown as follows, looks like it does not do anything. What is the problem of this scenario. I also include the detail of full.model in the following. > reduce.model<-step(full.model,direction="backward") Start: AIC=-121.19 y ~ as.matrix(x) Df Sum of Sq RSS AIC <none> 1.1 -121.19 -

Linear regression loop with data.table; “Error in data.table column or argument (nr) is NULL”

孤街浪徒 提交于 2020-01-06 05:27:14
问题 As my dataset is cumbersomely large, I would like to automate some procedures. I found this link, which proposes a linear regression loop, which for the dataset mtcars is as follows: data.table(mtcars)[, .(MyFits = lapply(.SD, function(x) if(is.numeric(x)) summary(lm(mpg ~ x)))), .SDcols = -1] I have tried to apply this onto my own dataset with limited succes. I do get the output but there is a problem. The result for some of the Fits is NULL, so when I try to do the suggested operation Fits[

How to debug “contrasts can be applied only to factors with 2 or more levels” error?

社会主义新天地 提交于 2020-01-06 01:56:32
问题 Here are all the variables I'm working with: str(ad.train) $ Date : Factor w/ 427 levels "2012-03-24","2012-03-29",..: 4 7 12 14 19 21 24 29 31 34 ... $ Team : Factor w/ 18 levels "Adelaide","Brisbane Lions",..: 1 1 1 1 1 1 1 1 1 1 ... $ Season : int 2012 2012 2012 2012 2012 2012 2012 2012 2012 2012 ... $ Round : Factor w/ 28 levels "EF","GF","PF",..: 5 16 21 22 23 24 25 26 27 6 ... $ Score : int 137 82 84 96 110 99 122 124 49 111 ... $ Margin : int 69 18 -56 46 19 5 50 69 -26 29 ... $

How do I change colours of confidence interval lines when using `matlines` for prediction plot?

寵の児 提交于 2020-01-05 05:57:42
问题 I'm plotting a logarithmic regression's line of best fit as well as the confidence intervals around that line. The code I'm using works well enough, except I'd rather that the confidence intervals both be "gray" (rather than the default "red" and "green"). Unfortunately, I'm not seeing a way to isolate them when specifying colour changes. I'd like for the regression line: lty = 1, col = "black" ; for confidence intervals to have: lty=2, col = "gray" . How can I achieve this? my code is of the

How to make group_by and lm fast?

限于喜欢 提交于 2020-01-04 21:33:34
问题 This is a sample. df <- tibble( subject = rep(letters[1:7], c(5, 6, 7, 5, 2, 5, 2)), day = c(3:7, 2:7, 1:7, 3:7, 6:7, 3:7, 6:7), x1 = runif(32), x2 = rpois(32, 3), x3 = rnorm(32), x4 = rnorm(32, 1, 5)) df %>% group_by(subject) %>% summarise( coef_x1 = lm(x1 ~ day)$coefficients[2], coef_x2 = lm(x2 ~ day)$coefficients[2], coef_x3 = lm(x3 ~ day)$coefficients[2], coef_x4 = lm(x4 ~ day)$coefficients[2]) This data is small, so performance is not problem. But my data is so large, approximately 1,000

R script - least squares solution to the following [duplicate]

本小妞迷上赌 提交于 2020-01-04 13:23:21
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Finding where two linear fits intersect in R Given some points on a graph (usually only about 6 or 7 points), I need to find a best fit solution where the solution consists of the following: Two linear lines The lines must intersect The intersection point (the x point) must lie between two values I specify (such as xLow and xHigh) How would I do this using nls (or something better?)? If there are multiple best

Outputting Regression results into a data frame in R

醉酒当歌 提交于 2020-01-04 02:06:07
问题 I was wondering if there is any command that can output the results of a lm model into a data frame in R like outest in SAS. Any ideas? I am running multiple models and I want the result to look like below - Model | alpha | Beta | Rsquared | F | df | model0 | 8.4 | ... | .... | ..| .. | model1 | ... | ... | .... | ..| .. | model2 | ... | ... | .... | ..| .. | The data i have is 'ds' which is - X1 | X2 | Y1 | .. | .. | .. | .. | .. | .. | .. | .. | .. | .. | .. | .. | And my code is a simple