linear-regression

Standarized residuals in SPSS not maching R rstandard(lm())

我们两清 提交于 2019-12-11 02:45:02
问题 While looking for a R related solution I found some inconsistency between R and SPSS (ver. 24) in computing standardized residuals in a simple linear model. It appears that what SPSS calls standarized residuals matches R studentized residuals I'm far for assuming there is a software bug somewhere, but clearly things differ between those two programs. Have a look at this example #generate data in R set.seed(111) y = rnorm(20, 0, 1) x = rnorm(20, 1, 1) #calculate and standarized residuals

biglm predict unable to allocate a vector of size xx.x MB

断了今生、忘了曾经 提交于 2019-12-11 02:36:53
问题 I have this code: library(biglm) library(ff) myData <- read.csv.ffdf(file = "myFile.csv") testData <- read.csv(file = "test.csv") form <- dependent ~ . model <- biglm(form, data=myData) predictedData <- predict(model, newdata=testData) the model is created without problems, but when I make the prediction... it runs out of memory: unable to allocate a vector of size xx.x MB some hints? or how to use ff to reserve memory for predictedData variable? 回答1: I have not used biglm package before.

Getting different result each time I run a linear regression using scikit

南笙酒味 提交于 2019-12-11 02:15:19
问题 Hi I have a linear regression model that i am trying to optimise. I am optimising the span of an exponential moving average and the number of lagged variables that I use in the regression. However I keep finding that the results and the calculated mse keep coming up with different final results. No idea why can anyone help? Process after starting loop: 1. Create new dataframe with three variables 2. Remove nil values 3. Create ewma's for each variable 4. Create lags for each variable 5. Drop

Bayesian fit of cosine wave taking longer than expected

旧巷老猫 提交于 2019-12-11 00:33:53
问题 In a recent homework, I was asked to perform a Bayesian fit over a set of data a and b using a Metropolis algorithm. The relationship between a and b is given: e(t) = e_0*cos(w*t) w = 2 * pi The Metropolis algorithm is (it works fine with other fit): def metropolis(logP, args, v0, Nsteps, stepSize): vCur = v0 logPcur = logP(vCur, *args) v = [] Nattempts = 0 for i in range(Nsteps): while(True): #Propose step: vNext = vCur + stepSize*np.random.randn(*vCur.shape) logPnext = logP(vNext, *args)

How can I extract the number of lines and the corresponding equations from a linear fit

五迷三道 提交于 2019-12-10 23:56:58
问题 I have data and I expect several linear correlations of the form y_i = a_i + b_i * t_i, i = 1 .. N where N is a priori unknown. The short version of the question is: Given a fit how can I extract N ? how can I extract the equations? In the reproducible example below, I have data (t,y) with corresponding parameters p1 (levels p1_1 , p1_2 ) and p2 (levels p2_1 , p2_2 , p2_3 ). Thus the data looks like (t, y, p1, p2) which has at most 2*3 different best-fit lines and the linear fit from has then

MATLAB: Piecewise function in curve fitting toolbox using fittype

早过忘川 提交于 2019-12-10 23:42:38
问题 Ignore the red fitted curve first. I'd like to get a curve to the blue datapoints. I know the first part (up to y~200 in this case) is linear, then a different curve (combination of two logarithmic curves but could also be approximated differently) and then it saturates at about 250 or 255. I tried it like this: func = fittype('(x>=0 & x<=xTrans1).*(A*x+B)+(x>=xTrans1 & x<=xTrans2).*(C*x+D)+(x>=xTrans2).*E*255'); freg = fit(foundData(:,1), foundData(:,2), func); plot(freg, foundData(:,1),

Using predict with svyglm

对着背影说爱祢 提交于 2019-12-10 20:38:35
问题 I have found some odd behavior with predict and the svyglm object from the survey package. If your newdata in predict has a factor/character with one level it spits out error: Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels This error makes sense if I was putting a one level variable as the predictor for a model, but for newdata I don't see the problem. With regular glm this works fine. MRE: library(survey)

Warning message 'newdata' had 1 row but variables found have 16 rows in R

一笑奈何 提交于 2019-12-10 17:49:46
问题 I am suppose to use the predict function to predict when fjbjor is 5.5 and I always get this warning message and I have tried many ways but it always comes so is there anyone who can see what I am doing wrong here This is my code fit.lm <- lm(fjbjor~amagn, data=bjor) summary(fit.lm) new.bjor<- data.frame(fjbjor=5.5) predict(fit.lm,new.bjor) and this comes out 1 2 3 4 5 6 7 8 9 10 11 5.981287 2.864521 9.988559 5.758661 4.645530 2.419269 4.645530 5.313409 6.871792 3.309773 4.200278 12 13 14 15

Are epochs and training steps the same thing?

拥有回忆 提交于 2019-12-10 17:43:46
问题 features = [tf.contrib.layers.real_valued_column("x", dimension=1)] estimator = tf.contrib.learn.LinearRegressor(feature_columns=features) y = np.array([0., -1., -2., -3.]) input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x}, y, batch_size=4, num_epochs=1000) estimator.fit(input_fn=input_fn, steps=1000) For example, do these "steps=1000" and "num_epochs=1000" mean exactly the same thing? If yes, why does it need to be duplicated? If not, can i set these two parameters differently? 回答1: Here

Extracting weights from FlinkML Multiple Linear Regression

核能气质少年 提交于 2019-12-10 17:42:59
问题 I am running the example multiple linear regression for Flink (0.10-SNAPSHOT). I can't figure out how to extract the weights (e.g. slope and intercept, beta0-beta1, what ever you want to call them). I'm not super seasoned in Scala, that is probably half my problem. Thanks for any help any one can give. object Job { def main(args: Array[String]) { // set up the execution environment val env = ExecutionEnvironment.getExecutionEnvironment val survival = env.readCsvFile[(String, String, String,