regression

Curve fitting for each column in Pandas + extrapolate values

那年仲夏 提交于 2019-12-06 05:19:30
I have a data set with some 300 columns, each of them depth-dependent. The simplified version of the Pandas DataFrame would look something like this: import matplotlib.pyplot as plt import numpy as np import pandas as pd from scipy_optimize import curve_fit df1 = pd.DataFrame({'depth': [1.65, 2.15, 2.65, 3.15, 3.65, 4.15, 4.65, 5.15, 5.65, 6.15, 6.65, 7.15, 7.65, 8.15, 8.65], '400.0': [13.909261, 7.758734, 3.513627, 2.095409, 1.628918, 0.782643, 0.278548, 0.160153, -0.155895, -0.152373, -0.147820, -0.023997, 0.010729, 0.006050, 0.002356], '401.0': [14.581624, 8.173803, 3.757856, 2.223524, 1

Multiple Linear Regression function in SQL Server

妖精的绣舞 提交于 2019-12-06 04:51:04
问题 I have developed Simple Linear regression function in SQL Server from here (https://ask.sqlservercentral.com/questions/96778/can-this-linear-regression-algorithm-for-sql-serve.html) to calculate Alpha,Beta and some extra values like Upper 95% and Lower 95%. The Simple Linear regression takes the argument as X and y. Now I am in need of perform Multiple Linear regression SQL Server, which takes arguments y and X1,X2,X3,.....Xn Hence the Output will be as follows: Coefficients Standard Error t

How to set the Coefficient Value in Regression; R

。_饼干妹妹 提交于 2019-12-06 04:44:17
问题 I'm looking for a way to specify the value of a predictor variable. When I run a glm with my current data, the coefficient for one of my variables is close to one. I'd like to set it at .8. I know this will give me a lower R^2 value, but I know a priori that the predictive power of the model will be greater. The weights component of glm looks promising, but I haven't figured it out yet. Any help would be greatly appreciated. 回答1: I believe you are looking for the offset argument in glm . So

Custom plots using the effects package

三世轮回 提交于 2019-12-06 04:36:28
问题 I try to customize the multiline graphs from the effects package. Is there anyway to position the legend in the example below within the plotting area and not above the graph? Alternatively: Does anyone know how to plot the results of the multiline regressions calculated by the effects package using ggplot2? I appreciate any help. Andy Example: library(effects) data(Prestige) mod5 <- lm(prestige ~ income*type + education, data=Prestige) eff_cf <- effect("income*type", mod5) print(plot(eff_cf,

How do I plot predictions from new data fit with gee, lme, glmer, and gamm4 in R?

三世轮回 提交于 2019-12-06 04:06:32
问题 I have fit my discrete count data using a variety of functions for comparison. I fit a GEE model using geepack , a linear mixed effect model on the log(count) using lme ( nlme ), a GLMM using glmer ( lme4 ), and a GAMM using gamm4 ( gamm4 ) in R. I am interested in comparing these models and would like to plot the expected (predicted) values for a new set of data (predictor variables). My goal is to compare the predicted effects for each model under particular conditions (x variables). Of

How can I omit interactions using stargazer or xtable?

五迷三道 提交于 2019-12-06 04:03:23
问题 Is it possible to omit interactions in stargazer using the omit option? Normally I would write the variable name into the omit=c('varname') but in the case of an interaction I do not know what to write. Any hints on that? How do you solve this problem in other packages like xtable ? \documentclass{article} \begin{document} %Load dataset and run regression << lm, echo=FALSE >>= load('dataset.RData') library(stargazer) lm1 <- lm(y~ x + factor(v)*z ,data=dataset) @ << table_texstyle, echo=FALSE,

difference between LinearRegression and svm.SVR(kernel=“linear”)

不打扰是莪最后的温柔 提交于 2019-12-06 03:45:49
问题 First there are questions on this forum very similar to this one but trust me none matches so no duplicating please. I have encountered two methods of linear regression using scikit's sklearn and I am failing to understand the difference between the two, especially where in first code there's a method train_test_split() called while in the other one directly fit method is called. I am studying with multiple resources and this single issue is very confusing to me. First which uses SVR X = np

Piecewise regression with a straight line and a horizontal line joining at a break point

☆樱花仙子☆ 提交于 2019-12-06 03:09:42
问题 I want to do a piecewise linear regression with one break point, where the 2nd half of the regression line has slope = 0 . There are examples of how to do a piecewise linear regression, such as here. The problem I'm having is I'm not clear how to fix the slope of half of the model to be 0. I tried lhs <- function(x) ifelse(x < k, k-x, 0) rhs <- function(x) ifelse(x < k, 0, x-k) fit <- lm(y ~ lhs(x) + rhs(x)) where k is the break point, but the segment on the right is not a flat / horizontal

Write Regression summary to the csv file in R

↘锁芯ラ 提交于 2019-12-06 03:01:26
问题 I have data on revenue of a company from sales of various products (csv files), one of which looks like the following: > abc Order.Week..BV. Product.Number Quantity Net.ASP Net.Price 1 2013-W44 ABCDEF 92 823.66 749 2 2013-W44 ABCDEF 24 898.89 749 3 2013-W44 ABCDEF 243 892.00 749 4 2013-W45 ABCDEF 88 796.84 699 5 2013-W45 ABCDEF 18 744.80 699 Now, I'm fitting a multiple regression model with Net.Price as Y and Quantity, Net.ASP as x1 and x2. There are more than 100 such files and I'm trying to

Fast group-by simple linear regression

大兔子大兔子 提交于 2019-12-06 02:29:39
问题 This Q & A arises from How to make group_by and lm fast? where OP was trying to do a simple linear regression per group for a large data frame. In theory, a series of group-by regression y ~ x | g is equivalent to a single pooled regression y ~ x * g . The latter is very appealing because statistical test between different groups is straightforward. But in practice doing this larger regression is not computationally easy. My answer on the linked Q & A reviews packages speedlm and glm4 , but