clustering by subjects in Nonlinear Least Squares in R - r

I would like to cluster standard errors at subject level in a nonlinear least square regression in R. Is it possible to do this with the nls command?

Related

comparison of goodness-of-fit under robust circumstances [migrated]

This question was migrated from Stack Overflow because it can be answered on Cross Validated.
Migrated yesterday.
I have fitted respectively a zero-knot, a one-knot and a two-knot linear spline to my data, and I need some index of goodness-of-fit for model selection. The crucial point is that the splines are fitted with robust linear regressions (using function rlm in R package MASS), specifically with Huber estimations and Tukey's bisquare estimation, which makes the usual estimator of prediction error like AIC inappropriate.
So my problem is:
What criterion should I use to perform model selection on my zero, one and two-knot splines? Can I use SSE?
I also need to compare between a model using Huber estimation and a model using Tukey's bisquare estimation. What criterion should I use?

How to find RERI for additive scale interaction in a cox regression model in R

I would like to find the RERI of an additive interaction for a COX regression model in R. Any idea if it's possible to do it, and if so, how to do it?
I know we can do it with stdReg package which is well explained here https://link.springer.com/article/10.1007/s10654-018-0375-y#Sec11, but the authors explain how to do it with two binary variables, and i would like to do it with 1 continous variable and 1 binary variable.

Does the function multinom() from R's nnet package fit a multinomial logistic regression, or a Poisson regression?

The documentation for the multinom() function from the nnet package in R says that it "[f]its multinomial log-linear models via neural networks" and that "[t]he response should be a factor or a matrix with K columns, which will be interpreted as counts for each of K classes." Even when I go to add a tag for nnet on this question, the description says that it is software for fitting "multinomial log-linear models."
Granting that statistics has wildly inconsistent jargon that is rarely operationally defined by whoever is using it, the documentation for the function even mentions having a count response and so seems to indicate that this function is designed to model count data. Yet virtually every resource I've seen treats it exclusively as if it were fitting a multinomial logistic regression. In short, everyone interprets the results in terms of logged odds relative to the reference (as in logistic regression), not in terms of logged expected count (as in what is typically referred to as a log-linear model).
Can someone clarify what this function is actually doing and what the fitted coefficients actually mean?
nnet::multinom is fitting a multinomial logistic regression as I understand...
If you check the source code of the package, https://github.com/cran/nnet/blob/master/R/multinom.R and https://github.com/cran/nnet/blob/master/R/nnet.R, you will see that the multinom function is indeed using counts (which is a common thing to use as input for a multinomial regression model, see also the MGLM or mclogit package e.g.), and that it is fitting the multinomial regression model using a softmax transform to go from predictions on the additive log-ratio scale to predicted probabilities. The softmax transform is indeed the inverse link scale of a multinomial regression model. The way the multinom model predictions are obtained, cf.predictions from nnet::multinom, is also exactly as you would expect for a multinomial regression model (using an additive log-ratio scale parameterization, i.e. using one outcome category as a baseline).
That is, the coefficients predict the logged odds relative to the reference baseline category (i.e. it is doing a logistic regression), not the logged expected counts (like a log-linear model).
This is shown by the fact that model predictions are calculated as
fit <- nnet::multinom(...)
X <- model.matrix(fit) # covariate matrix / design matrix
betahat <- t(rbind(0, coef(fit))) # model coefficients, with expicit zero row added for reference category & transposed
preds <- mclustAddons::softmax(X %*% betahat)
Furthermore, I verified that the vcov matrix returned by nnet::multinom matches that when I use the formula for the vcov matrix of a multinomial regression model, Faster way to calculate the Hessian / Fisher Information Matrix of a nnet::multinom multinomial regression in R using Rcpp & Kronecker products.
Is it not the case that a multinomial regression model can always be reformulated as a Poisson loglinear model (i.e. as a Poisson GLM) using the Poisson trick (glmnet e.g. uses the Poisson trick to fit multinomial regression models as a Poisson GLM)?

R) How can I do a multiple non-linear regression in R?

I used Curve Expert to get a non-linear equation for one y.
Now I have a two X, but don know how I have to merge this in one equation.
In other word, I want to know how I can do a multiple NON-linear regression with two non-linear equation in R.
Is there any packages for do this math or can I use nls function for this?

Obtaining outlier and collinearity diagnostics from the svyglm function in R

I am busy with a simulation study for my PhD where I am comparing output generated from ordinary least squares, weighted least squares and survey-weighted least squares regression applied to a stratified two-stage cluster sample. I've used influence.measures(), vif() and colldiag() on the ordinary least squares and weighted least squares regressions, but cannot find a clear answer as to how the same diagnostics can be obtained for svyglm(). Can these measures be obtained in R and if so, how?

Resources