752 questions
1
vote
1
answer
128
views
Why does my logistic curve_fit prediction return huge values although R² ≈ 0.99?
I’m trying to fit a logistic function to GDP data (China GDP dataset) using scipy.optimize.curve_fit.
The fitting looks very good (R² ≈ 0.99, curve matches the data), but when I try to predict a ...
2
votes
1
answer
72
views
How to set up non-linear (sinusoidal) multiple variable regression problems for tensorflow?
I have some parameters: A1, A2, A3, f1, f2, f3.
These parameters are then used to generate a set of sinusoidal data, something like:
y = A1 * sin(f1 * x) + A2 * sin(f2 * x) + A3 * sin(f3 * x)
From ...
2
votes
0
answers
101
views
Find necessary operators for symbolic regression
I wrote a symbolic regression tool in Python. It is possible to give unary and binary operators. If nothing is specified, I want to determine potential operators. So, I want to know if there is an ...
1
vote
0
answers
62
views
Pine script: how can I add a "Standard deviation channel" to a polynomial regression?
I have found a script for generating a polynomial regression, which I have adapted to my needs and which basically works.
However, in order to be able to use the script the way I want to, I need a ...
0
votes
1
answer
66
views
Smoothening of data in excel based on certain rules
I have following example data
The Figures depend on 3 parameters: X, Y & Rank. Out of these we are making 4 buckets. High X High Y, Low X Low Y, High X, Low Y and Low X, High Y. Then we are ...
2
votes
1
answer
73
views
Y-axis of mgcv::gam cox.ph model: rate or ratio?
I am plotting a nonlinear generalized additive model (gam) using R's mgcv package:
library(mgcv)
V <- rep(1, nrow(dt)
fit <- gam(cbind(V, group_number) ~ s(time_elapsed, exposure_group, bs='fs'...
0
votes
1
answer
71
views
crosspred from DLNM in R isn't accepting elements from a list?
I feel like I'm missing something really obvious here. I'm using the R package DLNM to fit a model. It's happening inside a function (not shown) so that I can feed in different datasets and change the ...
5
votes
1
answer
259
views
LOESS on very large dataset
I'm working with a very large dataset containing CWD (Cumulative Water Deficit) and EVI (Enhanced Vegetation Index) measurements across different landcover types. The current code uses LOESS ...
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 ...
3
votes
2
answers
113
views
Estimating non-monotonic bi-exponential curve fit
I am doing some pharmacokinetic analyses and am fine with non-compartmental methods. But I trying to also learn some non-linear curve-fitting techniques.
If we have the following data:
df <- data....
0
votes
1
answer
112
views
Correct calculation of r square (R^2) using visual basic WorksheetFunction.LinEst function
I have written visual basic code to determine the r square when fitting data using different order polynomials:
Linear
2nd order polynomial
3rd order polynomial
As an example, I have used the ...
0
votes
0
answers
62
views
Stata nonlinear least squares with many coefficients: shortening command
I want to estimate (the Greek characters are coefficients to be estimated):
where D_{it}^d are dummy variables (=0 or 1), and {\theta_i}_i,delta are to be estimated. i can be large, so there are a ...
2
votes
1
answer
162
views
Maximum number of function evaluations has been exceeded - increase MaxFunEvals option
I was trying to fit a data set into a sinusoidal function with the code below:
data = importdata('analisipicco.txt') ;
x = data(:,1) ; y = data(:,2) ;
yu = max(y);
yl = min(y);
yr = (yu-yl); ...
-1
votes
1
answer
64
views
How can we calculate mean absolute error (MAE) for zero-inflated Poisson regression and zero-inflated negative binomial regression?
I am trying to use Python to calculate mean absolute error (MAE) while doing zero-inflated Poisson regression and zero-inflated negative binomial regression.
I separated data into training data and ...
0
votes
1
answer
103
views
python non-linear regressor for incremental learning
I'm wondering if there is a non-linear regression routine with scikit-learn which allows for incremental learning, ie though the partial_fit call. I see that SGDRegressor and ...
0
votes
1
answer
150
views
Adding a covariate to an asymptotic regression model in R with nlme and SSasympOrig
I have two groups of data and reason to believe that they follow the same asymptotic curve with offset upper limits. All the observations are assumed to be independent. I fit a simple model with the ...
3
votes
2
answers
198
views
How to plot nonlinear regression function (nls) with ggplot2 geom_smooth using a self-starter function. Easy with drm, hard with nls
Similar to the post here: How to plot multiple `nls` fit curves with `geom_smooth()` (getting model parameters in the function call)
I want to plot a nonlinear regression output from nls with ggplot2 ...
0
votes
1
answer
139
views
Why do I get negative values for parameters in a curve fitting?
I'm trying to fit modeling data as a curve using Scipy's optimize curve_fit to some scattered data, but I got a negative value of (bX) parameter that makes no sense. So I'm not sure what is wrong with ...
0
votes
0
answers
60
views
I was trying to apply gradient descent manually, but facing a problem
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn....
0
votes
1
answer
60
views
What does assign(home=1) mean in Pandas Python?
I am trying to understand what the following snippet of the code does, in particular the assign(home=1).rename part:
goal_model_data = pd.concat([epl[['HomeTeam','AwayTeam','HomeGoals']].assign(home=1)...
3
votes
2
answers
227
views
Why does summary of bam model not work when using m=1 (generalised additive models)?
I'm trying to use bam() and method="fREML" to speed up my analyses.
require(mgcv)
require(gratia)
require(brms)
require(DHARMa)
require(marginaleffects)
mode11 <- bam(Met1 ~ s(Timepoint, ...
0
votes
0
answers
81
views
I'm training a model of machine learning polynomial regression using pytorch, and im getting errors while trying to plot the results of my predictions
I want to plot my data into a plt.scatter form but when I try to fill it, it just says that the x and y are not of the same size, and I also squeezed them to only one dimension so that it is easier to ...
0
votes
0
answers
234
views
At what point do I transform binomial predicitions on logit scale back to the response scale?
I am working with nest success data. Nests are either successful (1) or not (0), depending on whether or not a nest produces at least 1 hatchling. Because this is binomial data, I am running glmmer ...
0
votes
0
answers
97
views
Polynomial Regression with Non-Linear Constraints on R
I am not an expert with non-linear regression, but I struggle to make it work.
I would like to fit the polynomial f(x) = ax^3 + bx^2 + cx + d, with the following constraints on my parameters :
I want ...
0
votes
0
answers
815
views
How can I emulate Microsoft Excel's Solver functionality (GRG Nonlinear) in python?
Screenshot demonstrating the use of Excel's Solver:
I have a task to automate a certain excel worksheet. The worksheet happens to implement a logic with an excel plugin called Solver. It uses a ...
1
vote
0
answers
117
views
Bootstrapped confidence intervals for non-linear mixed effects model
I'm trying to get bootstrapped confidence intervals for parameter estimates of a non-linear (Gompertz) mixed effects model built in the lme4 package with function nlmer(). I need to be able to graph ...
0
votes
0
answers
55
views
Predict a predictor in a non-linear model
I have a non-linear model that I fit in brms:
mod <- bf(y~(I*N*X^b)/(A+k*B),
I ~ 1,
b ~ 1,
k~1+(1|group),
nl = T,
...
0
votes
1
answer
111
views
out of bounds error using nardl function in narld package
I run the example included in the documentation of the nardl function in the nardl package
############################################
# Fit the nonlinear cointegrating autoregressive distributed lag ...
0
votes
1
answer
152
views
How can I return A and b from this exponential fit function?
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.Optimization;
namespace ...
0
votes
0
answers
44
views
Plot of confidence limits changes when I change the axis ticks and labels for a polynomial regression
A multiple regression with number of days from start of observations gives me a plot in which the confidence limits are shown for the entire range of x-values of the curve. When I change the ticks and ...
2
votes
1
answer
1k
views
How can I do nonlinear regression using MathNet library?
I am trying to use MathNet library to compute curve fitting based on nonlinear regression.
using System;
using System.Linq;
using MathNet.Numerics;
using MathNet.Numerics.LinearAlgebra;
using MathNet....
1
vote
1
answer
142
views
Item-count technique/List experiment
I would like to conduct multivariate regressions analyses of survey data with the item count technique using ictreg but without success as I keep seeing the following error message "Error in ...
2
votes
1
answer
2k
views
How to perform piecewise linear mixed regression with multiple breakpoints in R?
I am fitting a piecewise linear mixed regression in R. I know that I can use lme from the nlme package followed by segmented to perform piecewise linear mixed regression. However, upon reading the ...
0
votes
1
answer
368
views
half-normal plot for a nonlinear model using the nls() function
I fitted a non-linear model to a dataset.
However, I need to perform the half-normal plot of this model (using the hnp() function from the hnp package).
My model was fitted considering the nls() ...
0
votes
0
answers
135
views
Linear regression for Physical problem predicting complex number (absolute and phase)
I am trying to do a linear regression which takes some physical measurements and then predicts various Physical values. One of these Physical values is a complex number, so I am trying to split it ...
1
vote
0
answers
799
views
Testing proportional odds assumption in R for ordinal logistic regression on ordinal variable with many categories
I'm trying to run an ordinal logistic regression to predict an ordinal variable with 8 categories (bins of # of days spent recreating) based on a categorical (BIPOC/not) and continuous (urbanicity ...
0
votes
0
answers
177
views
Diff-in-diff with count dependent variable: OLS vs Poisson vs Negative Binomial
I am estimating a diff-in-diff simple model with an interaction term consisting of the product between a dummy of treatment status (treat) and a dummy of post-treatment time period (pos). The ...
0
votes
0
answers
58
views
set up the initial guess values for curve_fit based on I/O
I am new in optimization and would like to write code that will determine the values of a1, a2, b1, b2 for a predefined function f_model based on the available inputs X1_data X2_data and output Y_list....
0
votes
0
answers
77
views
Using the drop.test function
So, I'm trying to test a hypothesis for a rank, nonparametric regression that none of the measured variables contributed significantly to the determination of the total triglyceride level. So, my ...
0
votes
0
answers
55
views
Problem fitting an nls function with a decreasing trend
For context, I have calculated 3 functional diversity indices from the potentially non-affected fraction (PNAF) of species at different dissolved oxygen concentrations. In order to fit a regression I ...
0
votes
1
answer
95
views
Why is nls() returning a negative standard deviation in R?
I am trying to model data as a normal curve in R. I am using the form of the equation:
Below is the code for calculation of equation parameters:
filtered_sp14 <- c(549.778714, 259.835892, 992....
0
votes
0
answers
41
views
MATLAB: Why is this code not running? I tried to make a surface fit and all variables are defined
%use fitobject = fit([x,y],z,fitType)creates a surface fit to the data in vectors x, y, and z.
fitobject = fit([t,omega_0],z,fitType);
fittype('A*cos(omega_0*t+phi)','problem',{'A','phi'},'options',fo)...
0
votes
1
answer
159
views
Non-linear regression analysis with a floor function on (X)
I have created a data set to understand better an equation and apply it to predict behavior.
The equation is y = 10/(1+k*⌊((x/t)^s)⌋).
To create the data set and see if it is working properly, I did ...
0
votes
1
answer
117
views
curve fitting of a non-linear model in shiny
I'm trying to fit some non-linear models in shiny to identify the best parameter values and then use them as initial values. As an example, I'm using a non-linear logistic model.
Below is the ...
2
votes
1
answer
998
views
Fitting data to a Boltzmann sigmoid function, and estimating parameters with a non-linear least squares fitting in R
I have a dataset of 10 subjects, whose muscle response amplitude was measured across 11 different stimulus intensities (states) applied to their muscles. The output curve of the data looks like a ...
1
vote
1
answer
914
views
Error in NLME function: Singularity in backsolve at level 0, block 1
I'm trying to fit ELISA plate data to a non-linear mixed effect model, using the nlme function. Previously, I asked about how to make the syntax work for nested groups, though responses made it seem ...
0
votes
2
answers
434
views
Using cluster-robust SEs within a zero-inflated negative binomial model through ggpredict won't return confidence intervals
I've been trying to apply cluster-robust standard errors in my calculation of the marginal effects of two predictor variables (main effects and their interaction) in a ZINB model. The code works ...
1
vote
1
answer
77
views
mean in Bayesian formula for non-linear modeling with brms
I am trying to fit non-linear models with brms. My model is:
y = intercept + b1 * (x1 * mean(x2^b2))
where:
x1 is a measured continuous variable,
x2 is also a continuous variable nested in x1. For ...
0
votes
1
answer
57
views
How to add random effects in a tree taper model?
I am learning to fit a tree taper mixed model using R. So I would like to know how can I add random effects in the model?
Let's say we fit the model using variable-exponent taper funtion of Kozak (...
0
votes
0
answers
453
views
Syntax for "groups" argument in R's nlme function; multiple groups
The crux of my problem (as far as I can tell) is that no examples are out there that give the proper syntax for nested groups when coding the groups argument of nlme. All examples only give a single ...