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`.

learn more… | top users | synonyms

0
votes
0answers
3 views

How to test if two cLogit coefficients are significantly different

I have the output of a cLogit test as shown below, but how do you test if the coefficients of two attributes are significantly different from each other? I have been playing with ...
1
vote
1answer
43 views

GLM model selection using AICc with Tweedie distribution

I have two questions regarding use of Tweedie GLM in R. I am new in using this distribution and despite a thorough search on different forums, I could not find my answers. I am now running several ...
0
votes
2answers
65 views

How to compare nested factor levels to mean, not to first level, and how to test the last nested level in R lm()

I have two factors j (with 3 levels A, B, C) and k (with 3 levels M, N, O), with k nested within j. Level A of j is the reference level and it has only one k level, M, in it. What I want to test ...
2
votes
1answer
48 views

Nonlinear total least squares / Deming regression in R

I've been using nls() to fit a custom model to my data, but I don't like how the model is fitting and I would like to use an approach that minimizes residuals in ...
1
vote
1answer
56 views

Power analysis for binomial test via simulation

Suppose a gene is mutated in 30% of the samples. I want plot the number of samples required to see 30% of them mutated at various level of power. I want to do this through a simulation so I ...
0
votes
0answers
21 views

Can anybody please help putting a 8 (4 row by 2 col) plots on one page? [migrated]

I am basically 8 different regression plots with similar data, and as you will I have legends inside each graph such as indications of: ...
1
vote
0answers
27 views

Comparing mixed-effects and fixed-effects models

Given three variables, y and x, which are positive continuous, and z, which is categorical, ...
1
vote
0answers
58 views

Calculate z-score in bootstrap

In my literature book I found that the z-score can be calculated by the following function: z = (data point - mean) / standard deviation Now I'm reading on bootstrap and I found that they ...
0
votes
1answer
21 views

Change settings in the prediction model (caret package)

I am using the package caret and GBM method for my predictions. ...
3
votes
1answer
96 views

Binomial distribution: calculating the probability of a given number of successes with R

I'm a bit lost here, could someone please enlighten me? Let's say we have this simple example: A 2005 survey found that 7% of teenagers (ages 13 to 17) suffer from an extreme fear of spiders ...
0
votes
1answer
29 views

Methods for determining cause and effect relationships between time lagged variables?

As you know, one can use regression for inference to learn which variables correlate with a response variable if the input predictors and the response share the same time frame. Let's say a predictor ...
1
vote
1answer
47 views

GBM: Predict the response variable measured in {0,20}

I need to predict the response that has values in {0,20}. Should it be used as a factor or as a numeric value? How does it influence on the prediction error? I am using GBM with the Gaussian ...
1
vote
1answer
110 views

Multicollinearity, plm, and omitting variables

I'm fitting a fixed effect model with plm and know that I'm dealing with multi-collinearity between two of the independent variables. I working on identifying ...
1
vote
0answers
6 views

Confusion about unpacking lists in R [migrated]

I'm befuddled by how R is dealing with lists and data frames. For example: ...
0
votes
0answers
22 views

R gives me the error “contrasts can be applied only to factors with 2 or more levels” running an mlogit model, but all my factors have 2 levels

I have a set of results from a choice experiment that I am trying to analyse using the mlogit function in R. My data set is shown below, where each STR value represents the three choices in a single ...
1
vote
1answer
59 views

Analyzing Ranked Data: Correlation and Factor Analysis?

I had survey respondents rank a series of items in order of importance, from 1 to 7. So, if a respondent assigned a score of 1 to one variable, then none of the other variables could get a 1 as well. ...
1
vote
0answers
35 views

rnorm vs numpy.random.randn

For a regression example, I constructed some artificial data and ran ols, ...
3
votes
0answers
49 views

Terrible logistic model gives perfect results? [duplicate]

So I'm playing around with logistic regression in R, using the mtcars dataset, and I decide to create a logistic regression model on the 'am' parameter (that is manual or automatic transmission for ...
0
votes
2answers
61 views

Calculate t-statistic step by step in R

Hello: I'm a faculty member teaching a stats class, and I'd like to show students how to calculate the t-statistic from an independent samples t-test (mostly) step-by-step. Using the code below, ...
0
votes
0answers
23 views

Correlation of Distance Matrix

I have a matrix with 15 samples and ~10,000 data points (all z-scores). I calculated a distance matrix with euclidean distances using R. Is it valid to calculate and present a correlation on this ...
1
vote
0answers
34 views

Bootstrap regression standard errors and re-calculate t-statistic?

I am working on a few (both simple and multivariable) regression analyses, and I have cases where the residuals are non-normal, to varying degrees. As I've understood, the Gauss-Markov theorem states ...
0
votes
1answer
18 views

Post Hoc Analysis in Mixed linear models

I tested whether different version-styles of a loading screen (hourglass vs. progress bar) in different progression patterns (linear, accelerate, decelerate, irregular, binary) affect time estimations ...
0
votes
1answer
16 views

Granger causality result interpretation in R

I am unable to interpret what this means.T2 is a zoo object containing two two price series. MSBVAR library of ...
0
votes
0answers
20 views

Interpreting tbats seasonal results for looking for the type of seasonality

Using tbatsfunction in R to look for seasonality. I test the seasonality for weekly and every 10 days and both have seasonality. ...
8
votes
0answers
76 views

How to calculate prediction intervals for LOESS?

I have some data that I fitted using a LOESS model in R, giving me this: The data has one predictor and one response, and it is heteroscedastic. I also added confidence intervals. The problem is ...
1
vote
1answer
48 views

Are different p-values for chi-squared and z test expected for testing difference in proportions?

I'm trying to test the difference in proportions using the z test method and chi-squared method, but am getting very different answers. Is that normal? My data: ...
0
votes
0answers
37 views

Am I coding and interpreting multiple Heaviside Functions correctly in a Cox model

I am wondering if I am coding multiple Heaviside Functions correctly in a cox model using R. There are plenty examples of Using 2 heaviside functions but i cannot find good examples of 3 or more HS ...
0
votes
0answers
20 views

Analyzing questionnaire data with control group

I have 12 questions weighted on a 5-point Likert scale. 20 people responded to each question, so we have 20 rows and 12 columns, with each cell ranging from 1 to 5. Questions 1-4 measure a random ...
0
votes
1answer
19 views

How do I do a conjoint analysis in R? I don't think the conjoint package is appropriate

We have conducted a conjoint survey of people's preferences when shopping for salmon. We have defined our salmon products in terms of "price" (20p steps from £3.60 to £5), "eco-certification" (none, ...
0
votes
0answers
18 views

Effect of Alpha and Lambda in Glm Net on Prediction Probabilties in Caret

I've run a number of different glm net classification models using Caret. I was trying to optimize by CV ROC and so tried a number of different tuning grids. Looking at several models with similar ...
0
votes
0answers
6 views

Convergence warnings with lme4 1.1.7 [migrated]

I run a simulation study fitting a GLMM random intercept model and I get warning messages. I tried various optimizers but they all give warning messages. Please find below one of the simulated ...
0
votes
0answers
16 views

How can I work out the response effect for categorical coefficients in a generalized linear model?

I have a set of different algorithms I would like to test on a set of different data. Running one algorithm on one datum gives a performance score. This score is log-normally distributed, and ...
0
votes
0answers
14 views

Fill under line curve [migrated]

For the sample dataset below, I would like to just plot the y as a smooth line with fill under the line using R. I am able to get smooth line but not the color filled curve. Could someone please ...
0
votes
0answers
34 views

Different results from randomForest via caret and the basic randomForest package

I am a bit confused: How can the results of a trained Model via caret differ from the model in the original package? I read Issue on prediction with FinalModel of RandomForest in R using the CARET ...
0
votes
0answers
6 views

R Package RMySQL: Can't convert character to VARCHAR MYSQL without errors [migrated]

So I'm using the RMySQL package to set up a local MYSQL server. I've set up a table but I'm having trouble with some of the data conversion types. In particular I've converted a date type in R to a ...
0
votes
0answers
7 views

Predict function error for probabilities in glmnet? [migrated]

I am trying to predict probabilities in a dataset using glmnet. My code reads: ...
0
votes
0answers
8 views

Error message fitting survival function with nls [closed]

I am trying to fit a survival function using nls as I had trouble with optim. This is full set of code I used. a=0.018 b=5.01 c=50000 d=2.29 ...
3
votes
2answers
95 views

R seasonal time series

I use the decompose function in R and come up with the 3 components of my monthly time series (trend, seasonal and random). If I ...
0
votes
0answers
16 views

hedonic model: estimating coefficients for variables not used in the regression

I'm trying to estimate the value of a real estate upon its characteristics. To do so, I'm using the Hedonic Model and I'm doing the regression using ...
2
votes
0answers
34 views

R: glm function with family = “binomial” and “weight” specification

I am very confused with how weight works in glm with family="binomial". In my understanding, the likelihood of the glm with family = "binomial" is specified as follows: $$ f(y) = {n\choose{ny}} ...
0
votes
0answers
13 views

Nested loops in R [migrated]

I've got a problem that I'm sure has a simple solution but I can't figure it out. Background: I've got several matrices which I have brought in to R, initially as a list but now they are in a ...
0
votes
2answers
31 views

arguments of length zero error with very similar code while forecasting

When I forecast from a linear Regression model in R using the following code, I get an arguments of length zero error , which I understand as a null pointer: ...
2
votes
1answer
42 views

Which model to use for survival analysis when there are different times of entry into the sample?

I have a data set containing the trades executed by many traders as follows: ...
1
vote
0answers
24 views

Multinomial regression in GLMNET

I'm working with a dataset that has multiple categorical classes that cannot be ranked into any relative or priority order. To approach this, I'm looking at glmnet's multinomial option. As I ...
0
votes
0answers
16 views

Using PCA and MANOVA to assess similarity of twins

the general answer to my question has been provided before ( Test if paired data are more similar than non-paired data ), but I'm very much out of my depth and would like to know if my implementation ...
2
votes
0answers
35 views

How can I get slope and standard error at several levels of a continuous by continuous interaction in R?

I'm comparing the slopes of several different response variables (DVs; representing different populations) to a set of predictors (IVs). For some DVs a 2-way interaction (continuous by continuous) is ...
0
votes
0answers
9 views

R “Entropy” package gives weird KL divergence results

Using the R "entropy" package, I tried some KL divergence computations as a sanity check, but I'm getting weird results. For instance, shouldn't the following all be 2*log2(2)= 2 ? Instead, I'm ...
3
votes
1answer
42 views

Predict the weekday of a recurring event and its probability

Suppose, we have 100 observations of variable X. X is the day of the week (Sunday – Saturday) when a specific event occurs on regular basis. E.g. when a postman delivers a package every week for 100 ...
0
votes
0answers
16 views

Code for Logistic Growth Model Returns Same as Exponential, Why?

I'm a brand new user of R. I was provided code for an exponential growth model. I need to modify the code to provide a logistic growth model for the carrying capacity of the population. I did so, ...
1
vote
0answers
21 views

Forecasting with use of PCA variables as independent and one ternary dependent variable in R

I'm having trouble in taking a direction of my research project. I have independent variables that are commonly used as economic indicators and I want to include variables/indicators that are not ...