Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

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

0
votes
0answers
12 views

How do I create scale scores from item-level multiply imputed data in R?

I have been able to create 5 multiply imputed datasets using the mice package on R. I computed at the item level so now I have to calculate scale scores for each of the 5 imputed datasets before ...
0
votes
0answers
89 views
+50

Logistic regression including instrumental variable (“ivprobit” in R) has coefficients with much reduced significance

I am trying to run a logistic regression including instrumental variables by using "ivprobit" function in R from the package called "ivprobit". If I do not include the instrumental variable, the "glm"...
0
votes
0answers
15 views

R: Anova() from car package not displaying F value [closed]

I am doing an anova and would like to get the F value as well. So far it is still doing a Wald chisquare test instead of an F-test. I don't understand what I am doing wrong. Car package version is 3....
0
votes
0answers
39 views

PDF of human population weight distribution

I have a lot of data on human weight coupled with information about gender, age, country and platform (desktop or mobile user). Looking something like this: ...
0
votes
0answers
11 views

Counting bifurcation of a dendrogram on R [closed]

I would like to write cumulative bifurcation number vs. distance(or height) graph from a dendrogram just like an attached image. This graph can show the how many levels of social organization are ...
1
vote
0answers
23 views

How do you stratify a Poisson regression in GLM?

I would like to obtain a stratified baseline hazard in a Poisson regression model. What is the correct way to do it ? Let A (=0/1) be the binary covariate on which I wish to stratify my baseline ...
-2
votes
0answers
29 views

What is wrong with for loop code? [migrated]

I have to create a function ans(k) that can return a vector with every Fibonacci number less than or equal to k. I know basics of loops but i am not able to understand the logic. Can someone please ...
0
votes
1answer
66 views

How can I better predict with (g)lmer with missing values?

Suppose I'm building a mixed model in R, and I want to use that model to predict new data for which I might not know the value of all the features. Or in some cases, it might not be so much that I don'...
0
votes
1answer
23 views

Custom Space State model using DLM in R

DLM package in R can model linear space state models of the form: I have a different category of equation which is also a linear polynomial equation of order 1 with constant coefficients. I would ...
0
votes
0answers
12 views

Reorganized Panel data in R

I am currently working on a fixed effect model, and have a dataset (csv file) in the form of the following (represents two city over three years): year feature1 feature2 2000 10 14 2001 12 13 2002 13 ...
0
votes
1answer
30 views

Natural spline term in GAM

Is it advisable to use natural regression spline basis? I learned that in R the supported smoothers in gam are the lo, ...
0
votes
0answers
31 views

How to calculate Sharpe Ratio? [closed]

I have a dataframe of stock daily stock prices from which I try to get the Sharpe Ratio ...
0
votes
0answers
15 views

Calculating annualized volatility from yearly returns

I have the yearly_return in percentage of some stocks and I would like to get the annualized volatil- ity. Yet when I tried to apply sd(yearly_return) it returned ...
0
votes
1answer
11 views

VAR order in Cointegration Test

I am studying Johansen's Test using Tsay's book (Multivariate Time Series Analysis). The book has given some sample results of function ca.jo in r package ...
0
votes
0answers
12 views

How does multicollinearity affect the feature selection process?

I have a classification problem with a modest number of records (approx. 10,000) and dimensions (30 dimensions, 25 are categoric and 5 are numeric). The response variable has two classes (T/F). I'm ...
0
votes
0answers
13 views

What is the logistic equation for a model with interaction [closed]

I have a GLM with four variables $Y = (X_1 + X_2) * (X_3 + X_4))$ $X_1$ = continuous variable $X_2$ = continuous variable $X_3$ = continuous variable $X_4$ = categorical variable (6 level = A, B,C,...
1
vote
0answers
22 views

Receiving singular fit error while using lmer on one computer but not another [closed]

I have a script with a multi-level models that appears as follows. X1 is continuous, X2 is dichotomous, there are 45 of subID and 296 trials for each subID.: Y ~ X1 * X2 + (X1 * X2| subID) When I ...
0
votes
0answers
4 views

Plotting Custom PDF in R [migrated]

Given: Consider the density function $\phi$ defined on $\mathbb{R}$ for $a\in \mathbb{R}$ and $b \in \mathbb{R}_+^\star$ such that $\forall x \in \mathbb{R}$, $$ \phi(x; a,b) = \frac{1}{\sqrt{2\pi b^...
2
votes
1answer
33 views

Effect of continuous variable with many repeated values on Random Forest

I am trying to build a random forest regression model in R using all continuous panel data. There is a large amount of data relative to the number of predictors. Say 500,000 rows and about 40 ...
1
vote
1answer
42 views

order of the time series model

I am kind of new to time series modeling. I am trying to fit a model for a time series variable. I am trying to fit a ARMA model. I am using R to do the analysis. When i estimate the model using both ...
1
vote
0answers
23 views

bam() error: “reparameterization unstable for margin: not done”

In running a large GAM model of the form mgcv::bam(y ~ te(x, y, k = 100, bs = 'ts'), family = binomial, discrete = TRUE) I get this warning <...
1
vote
2answers
40 views

R linear regression - how to handle when some factors significant while others aren't [duplicate]

I'm playing with the Titanic data set, and trying to figure out what to do about the results I got from a lm that predict the age of the passenger. How should I handle the Cabin values? Some Cabin ...
0
votes
0answers
7 views

Choice-based conjoint study with bayesm in R

I am conducting the analysis of a choice-based conjoint study using the package "bayesm" in R. Due to recent updates of the package I am no longer able to use the ...
2
votes
1answer
32 views

Generate value of variables for given correlation coefficient

I would like to generate test data for script used for correlation analysis between quite long variables. Is it possible for a given length of vectors, to generate in relatively simple way ...
0
votes
0answers
12 views

Environmental variables and management

I have a dataset with 7 forest sites, each with a paired managed and unmanaged stand. In these stands I have 4 - 19 plots where insects have been sampled. Additionally, we also collected a number of ...
3
votes
2answers
267 views

Simulating rnorm() using runif()

I am trying to 'simulate' rnorm() using only runif(). I don't know if I should do: sqrt(-2*log(U1))*cos(U2) or ...
-1
votes
0answers
21 views

How to convert hourly data to 6/12/24 hourly data in R? [closed]

I am new to R programming. As is seen in the data for a day, I have hourly rainfall data and I want to convert this hourly data to 6-hourly, 12-hourly and daily data as in the example. How can I ...
0
votes
0answers
12 views

Help in understanding notation for NO-GROWTH MODEL (OpenMx)

I´m having a hard time understanding the OpenMx notation from this handbook "Growth Modeling" (Grimm, Ram & Estabrook, 2017). The authors compare the script from MPlus and OpenMx with regard to ...
1
vote
0answers
46 views

How to estimate a bivariate probit (biprobit) model in R with a different set of explanatory variables?

I'm trying to estimate a bivariate probit model (also called biprobit model) in R where the set of explanatory variables is different for both binary outcomes. Thus, my setting is: $Y1^* = X1 + Y2 + ...
3
votes
2answers
65 views

Interpreting GAM Coefficients

I could use some advice interpreting GAM (Generalized Additive Model) coefficients. I get the following results when I call coef on my model: ...
1
vote
1answer
45 views

R: singular convergence in mixed effect model

I have an experiment that is designed as 6 blocks of 4 plots each, with two treatments (W_add and P_add) plus combination of treatments and control. The data are flux measurements taken during 9 ...
2
votes
1answer
20 views

Why are AUC and logloss metrics not available in the “maximum metrics” table produced by H2O? [closed]

I am running the h2o.gbm algorithm using five-fold cross validation to predict a binary outcome. I want to see what threshold to use as a cutoff for classifying predictions, and I am wondering why the ...
2
votes
0answers
12 views

Contribution of a predictor in Nonparametric regression

Is there an equivalent to a beta weights in a nonparametric regression? I am using the NP package in R and running a local linear regression where my bandwidth estimates are produced using least ...
1
vote
0answers
27 views

how to detect data scrambling

Suppose you ordered 50 different chemical products from a vendor. The products are delivered to you in vials, each labelled with a unique barcode, but completely identical in all other respects. The ...
0
votes
0answers
9 views

Mixed logit with repeated choices coefficient comparison

We are analysing data from the discrete choice experiment using mixed logit model. Data is panel, since we had repeated choices. We would like to compare if the difference in coefficients within the ...
1
vote
0answers
15 views

Which kind of diagnostic plots for count data? [duplicate]

I know that for an lm model is enough to run plot(model_lm) to get diagnostic plots. I am dealing with high-dimensional count ...
0
votes
1answer
48 views

Which statistical test should I use to determine whether a treatment affects different groups differently?

I am trying to determine if the treatment effect on different groups are statistically different using a statistical test. More specifically, my data is divided into 6 strata. and in each stratum ...
2
votes
0answers
18 views

Planned Contrasts in Mixed models: group with 3 levels

This analysis is based on data from https://stats.idre.ucla.edu/r/seminars/repeated-measures-analysis-with-r/ with some modifications. Pulse measurements were made at 3 time points (1,2,3) for study ...
0
votes
1answer
21 views

Linear mixed model with fixed effects in the residual variance

I would like to know how to structure a mixed effect model that allows for a) a fixed factor or b) a covariate to influence residual variance. I have a dataset of repeated observations from ...
0
votes
1answer
29 views

How do I show that a continuous variable is a predictor of categorical variable that takes the value of 1 or 0 using R

I want to perform a test to see if the continuous variable is a predictor of the categorical variable. More information: I was given identifier IDs with corresponding dichotomous values (Call it CD, ...
-1
votes
0answers
20 views

How to perform price optimization for multiple products? [closed]

I have multiple products with multiple price points for one product. I have to optimize the price of product. How to deal with it? With respect to sales, quantity, average selling price, customer ...
1
vote
1answer
35 views

Forecasting Methodology

Suppose I have only 1 variable (data on export, monthly, non-seasonally adjusted) from Jan 1960 till Mar 2019. My task is to obtain forecasts of this series for the coming year (i.e. Apr 2019 - Mar ...
1
vote
3answers
62 views

How do I model a dependent variable that is a proportion?

Problem I am trying to test gender differences in the risk propensity of investors related to specific kind of stocks. More specifically, I want to the test the hypothesis predicting that female ...
0
votes
0answers
14 views

How do I specify a moving average model in R-INLA?

I have a dynamic regression model specified as follows: $f_{c,t+1} \sim N(\eta_{c,t+1} + \phi\epsilon_t,\sigma^2_{f})$ $\epsilon_t=f_{c,t}-\eta_{c,t}$ $\eta_{c,t}=\beta_0+\beta_1x_{1,c,t}$ How ...
0
votes
0answers
18 views

Predicting the minimum score needed to win a contest [closed]

Given a nationwide contest with 1M contestants where the top 10 contestants that have answered the MOST correct answers in a test will be awarded a price. If we know already that at least 100 people ...
1
vote
1answer
37 views

Disagreement between p-values and bias corrected CI in path analysis

I am conducting a path analysis that include estimation of indirect effects (i.e. mediation). For each indirect effect specified in the model (a1*b1), I have both a p-value and a 95% boostrapped CI. ...
1
vote
0answers
16 views

Question on Task-Fullfillment in R [closed]

Yeah, so I'm working in R. And I have to check if the differences between two variables correlate with a another variable. So how do I do it? What is the command in R to check the correlation between ...
0
votes
0answers
16 views

Linearity problems and many factors R coding [closed]

I am working on a school project to analyze customer satisfaction in airlines based on many discrete data and some continuous variables. We must use R to analyze the data. I have used the plot() to ...
0
votes
0answers
14 views

Computing likelihood of data in R [duplicate]

Can you guys help me in this question? Let X1;...,Xn be a random sample from f(x, theta) =(1/theta)*exponential(-x/theta) with x>0, theta>0.Write a R function to compute the likelihood of the data. ...
3
votes
1answer
44 views

How to fit a weighted mixed effects model?

I am looking to get help into specifying the structure of the variance matrix within the gls() function in R's nlme package (or recommendations of other packages ...