Questions tagged [linearmodels]

A python package which provides estimation and inference in some common linear models including panel data and instrumental variables estimators. For questions related to implementation or interpretation of a linearmodels estimator.

linearmodels is a package which provides some more complex linear estimation techniques to Python, based around numpy and pandas.

Common linear models such as Two-stage least squares, Generalized Method of Moments etc. are missing from the popular statsmodels package and this package fills that gap.

141 questions
0
votes
0 answers

Linear_model.LinearRegression() coefficients are not same as Statsmodels model.summary

import statsmodels.api as sm x1 = np.array([3,4,6,8,9]) x2 = np.array([1,1,3,6,4]) x3 = np.array([2,2,5,6,9]) y = np.array([2,3,6,5,8]) xn1 = x1.reshape(-1,1) xn2 = x2.reshape(-1,1) xn3 = x3.reshape(-1,1) X =…
0
votes
1 answer

how to initiate a specific node as infected in Linear Threshold Model python

I'm trying to use the Linear Threshold Model in Python. I have a graph of nodes and I want to define one node that will be the first one infected. I saw that by using 'fraction_infected' I can choose a fraction of my nodes that will be infected in…
0
votes
0 answers

Visualization of two different two way interaction of three variables in one model (in R)

Suppose we have three independent variables X=(X_1, X_2, X_3), and a dependent variable Y. If we have a regression model as follow Y = \alpha+\beta_1 X_1 + \beta_2 X_2 + \beta_3 X_3 + \beta_{12} X_1 X_2 + \beta_{23} X_2 X_3 + \epsilon. Here is an…
Sedi
  • 1
  • 2
0
votes
2 answers

4. Now fit a linear model for each metric and use the confint function to compare the estimates. (Batting)

Here's what I've done so far, I'm having difficulty figuring out the regression line. Before we get started, we want to generate two tables. One for 2002 and another for the average of 1999-2001 seasons. We want to define per plate appearance…
math.where
  • 13
  • 4
0
votes
0 answers

Error in round(sw.fit, 2): non-numeric argument to mathematical function Traceback:

I know there are several answered questions regarding this error in R. However, I was not able to find one that could help me in my case. What I am trying to do is fit a multiple linear model in it and rounding the output that I get into 2 decimal…
0
votes
0 answers

Value error : Shapes not aligned in Multiple linear regression model

I am trying to build a linear model by using both Sklearn's linear regression and statsmodels.api. The approach is to drop variables whose p-values and VIF values are higher than the norm (p-value : 0.05, VIF : <5) bike_train columns are August,…
0
votes
1 answer

Pandas OLS Random Effects model - weird prediction values

I am trying to create a RE-model using Pandas. I only have previous experience in Stata. My aim is to generate predicted temperatures by regressing the temperature data on a set of dummies. The first set of dummies represents the month of the year…
timpan
  • 3
  • 2
0
votes
0 answers

aov and anova deliver different results

I do not understand why aov and anova deliver different results if I consider the same linear model. I first do this with aov function: res.aov <- aov(mRNA ~ Time, data= ID1.4.5.6.7) summary(res.aov) and the output is: Df Sum Sq Mean Sq F value…
Student.py
  • 225
  • 3
  • 14
0
votes
1 answer

how to set unstructured covariance matrix for random effect in linear mixed models in spss

I would like to ask how to set unstructured covariance matrix for random effect in linear mixed models in SPSS. When I do so in my SPSS (version 26) it is showing me in the output (in model dimension table) that covariance structure for random…
J. Krc
  • 47
  • 3
0
votes
0 answers

Unable to use the package called ‘car’ in RStudio and unable to use vif() because of that

I want to check the multicolinearity of variables in my lm model using vif(). It is throwing error and hence I am not able to use: > library(car) Error in library(car) : there is no package called ‘car’ > vif(mymodel3) Error in vif(mymodel3) :…
0
votes
1 answer

DESeq2 design matrix including RIN as covariate in the formula

I have been following the last DESeq2 pipeline to perform an RNAseq analysis. My problem is the rin of the experimental samples is quite low compared to the control ones. Iread a paper in which they perform RNAseq analysis with time-course RNA…
FrAoJm
  • 5
  • 1
0
votes
0 answers

sample code for Fama-MacBeth method in LinearModels python

is there anyone who would be willing to share a sample code for a fama-macbeth regression in python 3? i couldn't really find anything online that allows me to replicate into my research. thanks in advance
0
votes
1 answer

Bootstrapping "lme()", nlme, by lmeresampler

Does anyone know how to bootstrap a linear mixed-effect model constructed by lme function (nlme package)? Half year ago I was able to do that by "bootstrap" function from "lmeresampler" package, but it doesn't currently run with the same data and…
Mmm
  • 11
  • 1
0
votes
0 answers

problem using sklearn.pipeline with GaussianNB

I want to test a sentiment model this is a part of my code. sentiment_model = Pipeline([ ('vectorizer', TfidfVectorizer(binary=False, strip_accents='ascii', stop_words=stop_words_Evaluacion_entre_Pares, ngram_range=(1,2))), ('tfidf',…
0
votes
0 answers

Regressing along time in a three-dimensional Pandas dataframe

I have a dataset that consists of five signals measured over time. In a given data file, each timestamp corresponds to a unique measurement position. The positions repeat in each file, but the time spacing is irregular. I would like to calculate a…
scox
  • 1
  • 1