regression

Scikit Learn sklearn.linear_model.LinearRegression: View the results of the model generated

扶醉桌前 提交于 2021-01-28 07:22:22
问题 So, I can get sklearn.linear_model.LinearRegression to process my data - at least to run the script without raising any exceptions or warnings. The only issue is, that I am not trying to plot the results with matplotlib, but instead I want to see the estimators and diagnostic statistics for the model. How can I get a model summary such as the slope and intercept (B0,B1), R squared adjusted, etc to display in the console or populate into a variable instead of plotting this? This is a generic

Gaussian Process Regression: standard deviation meaning

不想你离开。 提交于 2021-01-28 05:58:20
问题 In the following code about the Gaussian Process Regression (GPR): from sklearn.datasets import make_friedman2 from sklearn.gaussian_process import GaussianProcessRegressor from sklearn.gaussian_process.kernels import DotProduct, WhiteKernel X, y = make_friedman2(n_samples=500, noise=0, random_state=0) kernel = DotProduct() + WhiteKernel() gpr = GaussianProcessRegressor(kernel=kernel, random_state=0).fit(X, y) print gpr.score(X, y) print gpr.predict(X[:2,:], return_std=True) What is the

Gaussian Process Regression: standard deviation meaning

瘦欲@ 提交于 2021-01-28 04:51:40
问题 In the following code about the Gaussian Process Regression (GPR): from sklearn.datasets import make_friedman2 from sklearn.gaussian_process import GaussianProcessRegressor from sklearn.gaussian_process.kernels import DotProduct, WhiteKernel X, y = make_friedman2(n_samples=500, noise=0, random_state=0) kernel = DotProduct() + WhiteKernel() gpr = GaussianProcessRegressor(kernel=kernel, random_state=0).fit(X, y) print gpr.score(X, y) print gpr.predict(X[:2,:], return_std=True) What is the

Running multiple simple linear regressions from a nested dataframe/tibble

不问归期 提交于 2021-01-28 04:26:50
问题 I am trying to run multiple simple linear regressions based on data from a nested data frame and store the regression fit coefficients in a dataframe using tidy(). My code block is as follows library(tidyverse) library(broom) library(reshape2) library(dplyr) Factors <- as.factor(c("A","B","C","D")) set.seed(5) DF <- data.frame(Factors, X = rnorm(4), Y = rnorm(4), Z= rnorm(4)) MDF <- melt(DF, id.vars=c("Factors","X")) DFF <- MDF %>% nest(-Factors) If it is a single dataframe with many columns,

Most efficient way to run regression models for multiple independent variables on the same list of 80 dependent outcomes?

爷,独闯天下 提交于 2021-01-28 01:48:59
问题 What is the most efficient way to run regression models for a list of 20 independent variables (e.g. genetic variants, each of these genetic variants will be tested alone) and 40 dependent variables? I am a beginner to R! I found a solution but it would work only if I had 1 independent variable. Not sure how I would go about if I had many (http://techxhum.dk/loop-multiple-variables/) Thanks for your time. 回答1: Here's a somewhat dense solution that uses the mfastLmCpp() function from the MESS

Running multiple simple linear regressions from a nested dataframe/tibble

折月煮酒 提交于 2021-01-27 22:50:47
问题 I am trying to run multiple simple linear regressions based on data from a nested data frame and store the regression fit coefficients in a dataframe using tidy(). My code block is as follows library(tidyverse) library(broom) library(reshape2) library(dplyr) Factors <- as.factor(c("A","B","C","D")) set.seed(5) DF <- data.frame(Factors, X = rnorm(4), Y = rnorm(4), Z= rnorm(4)) MDF <- melt(DF, id.vars=c("Factors","X")) DFF <- MDF %>% nest(-Factors) If it is a single dataframe with many columns,

Extract lists of p-values for each regression coefficients (1104 linear regressions) with R

北战南征 提交于 2021-01-27 19:45:16
问题 I try to do 1104 linear regressions with the same model. My independent variable does not change. However, my dependant variable does. Indeed, I have 1104 dependent variables. I can only extract all the coefficients (intercepts included), t-stats and R-square stats. I would also like to extract all the p-values lists of each coefficients within the 1104 linear regressions. How to do that with an easy way ? Here are my codes: run 1104 regressions for M1 bigtest<-as.data.frame(bigtest) test <-

R: Dynamically update formula

十年热恋 提交于 2021-01-27 07:54:02
问题 How can I dynamically update a formula? Example: myvar <- "x" update(y ~ 1 + x, ~ . -x) # y ~ 1 (works as intended) update(y ~ 1 + x, ~ . -myvar) # y ~ x (doesn't work as intended) update(y ~ 1 + x, ~ . -eval(myvar)) # y ~ x (doesn't work as intended) 回答1: You can use paste() within the update() call. myvar <- "x" update(y ~ 1 + x, paste(" ~ . -", myvar)) # y ~ 1 Edit As @A.Fischer noted in the comments, this won't work if myvar is a vector of length > 1 myvar <- c("k", "l") update(y ~ 1 + k

R: Dynamically update formula

断了今生、忘了曾经 提交于 2021-01-27 07:50:10
问题 How can I dynamically update a formula? Example: myvar <- "x" update(y ~ 1 + x, ~ . -x) # y ~ 1 (works as intended) update(y ~ 1 + x, ~ . -myvar) # y ~ x (doesn't work as intended) update(y ~ 1 + x, ~ . -eval(myvar)) # y ~ x (doesn't work as intended) 回答1: You can use paste() within the update() call. myvar <- "x" update(y ~ 1 + x, paste(" ~ . -", myvar)) # y ~ 1 Edit As @A.Fischer noted in the comments, this won't work if myvar is a vector of length > 1 myvar <- c("k", "l") update(y ~ 1 + k

What is causing this error? Coefficients not defined because of singularities

♀尐吖头ヾ 提交于 2021-01-27 03:53:47
问题 I'm trying to find a model for my data but I get the message "Coefficients: (3 not defined because of singularities)" These occur for winter, large and high_flow I found this: https://stats.stackexchange.com/questions/13465/how-to-deal-with-an-error-such-as-coefficients-14-not-defined-because-of-singu which said it may be incorrect dummy variables, but I've checked that none of my columns are duplicates. when I use the function alias() I get: Model : S ~ A + B + C + D + E + F + G + spring +