Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 1569

Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer, & (b) is not *just* about how to use `R`.

7 votes
Accepted

df missing in R output of chi-square- test?

You've specified simulate.p.value = TRUE, so chisq.test will use a test statistic and P-value based on a Monte Carlo approach. In this case, there is no assumed chi-square distribution for the test st …
Hong Ooi's user avatar
  • 8,349
2 votes
Accepted

Is there an easy way to combine two glm models in R?

Do you want to take the average of the predicted probabilities, or the average of the coefficients? They will give different results, because a logistic regression involves a nonlinear transform of th …
Hong Ooi's user avatar
  • 8,349
2 votes
Accepted

How to get LogLiklihood value from logistic regression in R

Have you tried logLik(lrfit1)?
Hong Ooi's user avatar
  • 8,349
3 votes

R sparse smoothing splines

In R, you can fit them using a variety of functions, with lme in package nlme probably being a good place to start. …
Hong Ooi's user avatar
  • 8,349
1 vote

OLS in R with linear inequality constraints on coefficients

You can use constrOptim to minimise the RSS, subject to the constraints. There's an example in Modern Applied Statistics with S of using optim to do logistic regression via direct minimisation of the …
Hong Ooi's user avatar
  • 8,349
2 votes

How to prune a decision tree properly in R

To put every observation into its own leaf, use minbucket=2, minsplit=1, cp=-1. The negative value for cp is to ensure that rpart doesn't end splitting prematurely. You probably don't want to put eve …
Hong Ooi's user avatar
  • 8,349
2 votes

How to pass character strings to R from IML Studio

When R is involved, IML generates R code to treat x as a symbol rather plain text. … Alternatively, you could use the ExportMatrixToR module to send the data to R: start func(a); run ExportMatrixToR(a, "a"); submit / R; print(a); endsubmit; finish; Caveat: untested code …
Hong Ooi's user avatar
  • 8,349
2 votes

Difference in output from mvtnorm and Mathematica/Java

Note that the covariance matrix of $(x, y)$ doesn't have unit diagonals, so specifying corr as an argument to pmvnorm provides incomplete information. You need to specify sigma, which is the covarianc …
Hong Ooi's user avatar
  • 8,349
5 votes
1 answer
779 views

Replicating R model in SAS

I've got a model that I've developed in R, but also need to express in SAS. … I can fit this in R using gls() and the varComb and varIdent functions. …
Hong Ooi's user avatar
  • 8,349
12 votes
Accepted

How to fit data that looks like a gaussian?

x <- seq_along(r) f <- function(par) { m <- par[1] sd <- par[2] k <- par[3] rhat <- k * exp(-0.5 * ((x - m)/sd)^2) sum((r - rhat)^2) } optim(c(15, 2, 1), f, method="BFGS", control …
Hong Ooi's user avatar
  • 8,349
15 votes
Accepted

What is lambda in an elastic net model (penalized regression)?

You're confused; $\alpha$ and $\lambda$ are totally different. $\alpha$ sets the degree of mixing between ridge regression and lasso: when $\alpha = 0$, the elastic net does the former, and when $\al …
Hong Ooi's user avatar
  • 8,349
7 votes
3 answers
3k views

SAS/IML compared to R

I was wondering if anyone had experience with SAS/IML and R, and can give some pointers as to the relative advantages/disadvantages of the two. … I've used R extensively for programming and statistical analyses, but haven't had much experience with IML. …
Hong Ooi's user avatar
  • 8,349
47 votes
Accepted

When should I *not* use R's nlm function for MLE?

There are a number of general-purpose optimization routines in base R that I'm aware of: optim, nlminb, nlm and constrOptim (which handles linear inequality constraints, and calls optim under the hood) …
Hong Ooi's user avatar
  • 8,349
11 votes

R optim function - Setting constraints for individual parameters

You can set the constraints for the unconstrained parameters to $\pm \infty$ (and the ceiling for the non-negative parameters to $+\infty$). optim(par=theta, fn=min.RSS, lower=c(0, -Inf, -Inf, 0), u …
Hong Ooi's user avatar
  • 8,349
1 vote
1 answer
554 views

Specifying seasonality in a grouped ARIMA model with fable

I'm using Rob Hyndman's groovy new tidyverts family of packages (the replacement for forecast). I was just wondering how you'd specify that the data is seasonal, especially in the presence of groups. …
Hong Ooi's user avatar
  • 8,349

15 30 50 per page