9,412 questions
Advice
0
votes
0
replies
30
views
Time-based regression: is it leakage if training includes snapshots closer to the event than those used at prediction?
I’m building a regression model that predicts the final number of vehicles booked for a ferry trip.
Each training row represents the state of bookings for a given trip N days before departure.
Example ...
2
votes
0
answers
96
views
multinom standard errors change when scaling variable
I have the following R code that performs a multinomial logistic regression.
When scaling birthweight from grams (original data) to kg (more similar scale as other variables and easier interpretation) ...
Advice
0
votes
2
replies
52
views
Detect non-linear regression patterns in multiple univariate analyses
I have a dataset with around 10,000 continuous variables (gene abundances) in 200 samples, and also some parameters of these samples (e.g., pH). I am trying to see if there are any genes whose ...
Advice
0
votes
1
replies
87
views
Regression analysis
How should I handle a mass-point in the dependent variable when running OLS regression in R?
I’m working with a a household expenditure dataset (Living Costs 2019) where the dependent variable is the ...
0
votes
0
answers
25
views
How to generate a simple ARIMA process with statsmodels
I am trying to generate an ARIMA process with statsmodels. I tried already different combinations but nothing works. There is also nothing in the documentation that could solve my problem. The ...
0
votes
0
answers
82
views
True slope parameter for quantile regression with heterogeneous error [migrated]
I am trying to perform a Monte-Carlo simulation on quantile regression using R. Currently I am getting stuck simulating the data from the model below.
Y=beta_0+beta_1*X1*u1+u2
where, u2~N(0,1),u1~exp(...
Tooling
0
votes
5
replies
111
views
Deming Regression R - Prediction/Confidence Interval and use of total least squares
I want to use deming regression for the calculation of a linear function between two variables which both have measurement errors. In addition, I have to assume that the regression goes through the ...
0
votes
1
answer
84
views
Testing equality of multivariate coefficients with linearHypothesis()
I would like to conduct a F-test (Wilks' Lambda test, ideally) to test the equality of the slope coefficients for a single independent variable on two dependent variables. Using the mtcars dataset, ...
2
votes
1
answer
79
views
Deming Regression in R, Error Message if CV=TRUE
I would like to perform a Deming regression through the origin including a ratio of variance of 2.1 between the x and y variable, as the data I am working with includes measurement errors in the x and ...
0
votes
0
answers
40
views
How do I interpret Gaussian process parameters?
I'm performing Gaussian process regression using GPyTorch. I'm modeling two correlated tasks as follows:
class MyModel(gpytorch.models.ExactGP):
def __init__(self, X, Y, likelihood):
super(...
2
votes
0
answers
102
views
scipy.odr.ODR fails when y_err (sy) is provided - "Problem is not full rank at solution"
I'm potentially interested in performing ODR for some laboratory data, so I have started to play around with scipy.odr using fake data, just for the sake of learning. In this fake data example, ...
1
vote
1
answer
67
views
Combining lines in a predicted probability plot without changing the regression model
I have a dataset with a binary outcome income and two continuous predictors, age, and education_num. I'm fitting a logistic regression model with a natural spline for age and an interaction with ...
0
votes
0
answers
58
views
How do I create a multitask GPyTorch model with a user-specified noise covariance matrix?
I've implemented standard homoskedastic multitask Gaussian process regression using GPyTorch as follows:
class MyModel(gpytorch.models.ExactGP):
def __init__(self, X, Y, likelihood):
super(...
2
votes
1
answer
209
views
Fine-Gray vs Cause-Specific Cox Regression: Correct Code for sHR and csHR in R
I am analyzing competing risks data in R and want to confirm that I’m setting up both Fine-Gray and cause-specific Cox regression correctly.
My dataset encodes the event status as:
status = 1: ...
-2
votes
5
answers
174
views
Get dataframe of observations dropped in estimates
When you estimate a model, the estimation function will drop observations (i.e., rows) for which at least one variable (i.e., column) used either in the LHS or in the RHS of the formula is missing.
...
0
votes
0
answers
65
views
CUDA error 700: an illegal memory access was encountered
I encounter error:
Application terminated with error: ??+0 (0x709D9F003D8A)
??+0 (0x709D9E884BA4)
??+0 (0x709D9E9F388C)
??+0 (0x709D9FF2FCF5)
??+0 (0x709D9FF31448)
??+0 (0x709D9EB84E21)
??+0 (...
2
votes
0
answers
49
views
"non-conformable arguments" error getting predict for polr model
I'm following this to get proportional odds regression for a likert scale but I'm getting this error when I try to use predict:
Error in X %*% object$coefficients : non-conformable arguments
This is ...
0
votes
1
answer
89
views
In R, how do you get the Beta coefficient and 95% CI of a dropped level of a categorical variable when using deviation coding in quantile regression?
Sample Code
library(quantreg)
df <- data.frame(
outcome = c(10, 12, 14, 11, 13, 15, 9, 8, 10),
group = factor(c("A", "A", "A", "B", "B", "...
2
votes
1
answer
135
views
Ridge Polynomial Regression: How to get parameters for equation found
I've used sklearn for polynomial ridge regression. Using grid search, I am happy with the results. Now I would like to render it as a simple polynomial equation to run in a small python module. The ...
0
votes
0
answers
35
views
Can I use fitnet with softmax at the output layer for regression task, where output should be [0, 1] and their sum =1?
am performing regression analysis using the fitnet function to develop a supervised neural network that acts as a surrogate model. The training target data have specific constraints: all outputs must ...
2
votes
1
answer
68
views
Building a sklearn compatible estimator: 'dict' object has no attribute 'requires_fit'
I am trying to build a scikit-learn compatible estimator. I have built a custom class that inherits from BaseEstimator and RegressorMixin. However, when I try to use this, I run into an AttributeError:...
0
votes
1
answer
101
views
Simulating a Discrete-Choice/Multinomial Model
I want to simulate a Discrete-Choice/Multinomial model. Consider the situation where I have 100 people each with four choices (1 = air, 2 = bus, 3 = car, 4 = train).
There is a baseline preference ...
0
votes
0
answers
78
views
parallel = FALSE gives error in vglm() function but not when set to TRUE
I'm analyzing a dataset on student performance from this site called "student-mat.csv", and I'm working on an ordinal logistic regression model. I want to use the vglm() function from the ...
0
votes
0
answers
56
views
mvord package error in R: "no terms component nor attribute" when developing multivariate ordered probit model
I'm trying to fit a multivariate ordinal probit model using the mvord package in R. I have two ordered outcome variables (transit.commute.freq.pre.agg and transit.commute.freq.agg), each with a ...
2
votes
1
answer
105
views
Why is there a major difference in R-Squared between my models created with the same data? [closed]
I created two models using the lm() function in R. The first model, I created the design matrix for my prediction variable and then fed that into the lm() function.
copy <- data.frame(mtcars)
...
3
votes
0
answers
80
views
Orthogonal Distance Regression (ODR) convergence on valid data
I have some real data points, and I'm trying to use the ODR to fit linear regression and also output the uncertainty error of the slope.
import numpy as np
from scipy.odr import ODR, Model, RealData
...
4
votes
0
answers
133
views
Symbolic regression with integer parameters
I have a project of a symbolic regression (here on GitHub).
I use first curve_fit of scipy to find parameters with linear expressions (see fit function line 85 of file sr.py) but for non linear ...
3
votes
1
answer
55
views
How can I impute missing date values by using the average difference between two date columns?
Thanks in advance for any help you can provide. I have a dataset containing some healthcare data and am trying my hand at using python for EDA/regression modeling on the set. I have one date column [...
-1
votes
1
answer
62
views
Multiple Regression Especification in one Plots [closed]
I'd like to make a plot like in R
But, I have no idea how to do it. Can some of you help me?
The plot shows the coefficients and Confidence intervals for several regressions and each specification ...
2
votes
0
answers
306
views
did_multiplegt_dyn estimate effects for non-absorbing treatment (R)
I am trying to use the did_multiplegt_dyn package to estimate 2 different DiD models, one in which treatment is absorbing and one in which it is non-absorbing. That is, subjects may switch in and out ...
0
votes
0
answers
30
views
How to proof two way fixed effect model implies parallel trend assumption?
I try to figure out if a two-way fixed effect model (TWFE) implies parallel trend assumption--which further implies that difference in difference generalizes TWFE. However, I find some problems.
I ...
1
vote
1
answer
116
views
Is it possible to kill specific coeffients in polynomial regression model?
I need to make a multivariate polynomial regression. The code is based on https://saturncloud.io/blog/multivariate-polynomial-regression-with-python/.
So for my specific task I need to "kill"...
2
votes
1
answer
41
views
set.vertex.attribute ignoring relevel for ERGM in R
I am trying to calculate the probability that being from university 1 affects edge formation in an ERGM. However, I can't seem to change the reference category from 1 to something else.
D1 <- ...
2
votes
1
answer
102
views
Save stargazer table as JPG image
I am running some regression tables with stargazer. Is there any way I could save them directly as JPGs or any other image format.
Here is some sample code:
library(stargazer)
data(mtcars)
model1 <...
0
votes
0
answers
27
views
Logistic regression variables correlation but low GVIF
I'm making a logistic regression model to predict female presence on boards in tech SMEs. I was going to take out companies with only 1 employee, as they don't have boards, but my supervisor told me ...
1
vote
1
answer
124
views
Differences in R and Stata in logistic regressions [closed]
So I'm replicating a paper, most probably done on Stata judging by the appearance of the graphs. However I'm using R, and while the numbers are exactly the same when it comes to variable construction, ...
1
vote
1
answer
97
views
Why do model.evaluate() vs. manual loss computation with model.predict() in tf.keras do not add up?
I use keras and tensorflow to train a 'simple' Multilayer Perceptron (MLP) for a regression task, where I use the mean-squared error (MSE) as loss-function. I denote my training data as x_train, ...
1
vote
1
answer
79
views
Regression error with Python tensorflow keras
could someone please help me to fix the following error :
[AttributeError: 'super' object has no attribute 'sklearn_tags']
based on my code :
from tensorflow import keras
from scikeras.wrappers ...
1
vote
0
answers
43
views
rms::pentrace() grid set-up
In the R package rms, the pentrace() function enables penalized maximum likelihood estimation on a regression model that was initially fitted using unpenalized methods. The function needs a grid of ...
0
votes
0
answers
20
views
Get analytical equation of RF regressor model [duplicate]
I have the following dataset:
X1 X2 X3 y
0 0.548814 0.715189 0.602763 0.264556
1 0.544883 0.423655 0.645894 0.774234
2 0.437587 0.891773 0.963663 0.456150
3 ...
6
votes
1
answer
82
views
Does the way you numerically encode data for a regression matter? [closed]
I'm looking to build out a multiple regression in Python and need to numerically encode my categorical data. I have fields such as gender (Male, Female, Prefer not to Say), education level (High ...
0
votes
2
answers
108
views
Regression fails with poor initial guess [closed]
Consider a regression task where the parameters of the model differ significantly in magnitude, say:
def func(x, p):
p1, p2, p3 = p
return np.sin(p1*x) * np.exp(p2*x) * p3
# True Parameters:
...
0
votes
0
answers
53
views
Event Study Design using OLS yields estimates despite no variance in outcome variable
I am running an event study design and get some unexpected behavior using OLS. One of my outcome variables is by definition zero before the treatment, i.e., whenever event time is weakly smaller than ...
0
votes
0
answers
27
views
Validity of forcing line through origin in multiple regression
I am trying to fit a multiple regression model to my data. I am testing the hypothesis that outcome Y is linearly related to independent variable X, while controlling for a linear relationship with ...
2
votes
1
answer
191
views
Creating a specific B-spline basis matrix
Suppose I have data x = (x_1,...,x_n). I would like to create a basis matrix in R whose (i,j)th entry is B_j(x_i) - B_j(0), where B_j(.) is the jth cubic B-spline basis function. Is this possible to ...
3
votes
1
answer
68
views
Interaction - stratification or adjusting?
I am just wondering how I can show the result that takes into account the interaction between certain independent variables. I learned that if interaction is significant or interaction is considered ...
0
votes
0
answers
53
views
Is there a stepwise selection package in R for COX Mixed model?
Can stepwise selection method be used in COX Mixed model with R? lmerTest and cAIC4 packages both don't work.
In addition, is LASSO a better process to select predictors for regression models, ...
0
votes
1
answer
97
views
Comparing nls() to nls2() - what am I doing wrong
I am trying to emulate an nls() fit with nls2() via brute-force, when nls() works, so that I can look to a second option when it doesn't.
What am I doing wrong in how I have specified nls2() below? Is ...
0
votes
2
answers
136
views
Function with two variables - Polynomial fit Python
I have various pump performance data, and I am trying to fit curves as a combination of them.
In below image, different curves are at different pump speeds (RPM), and the Y axis is Pressure head, and ...
1
vote
3
answers
185
views
How to extract Std.Dev from VarCorr glmmTMB
I'm using the emmeans package with a negative-binomial model implemented using the glmmTMB package. I'm trying to bias adjust my backtransformed emmeans per the workflow illustrated here: https://cran....