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
9 views

How to model count data with decay

I'm trying to understand how I might model count data where there's diminishing marginal utility and a stochastic process. So, let's say we're modeling the number of "useful intelligence tips" given ...
0
votes
0answers
24 views

Sentiment Analysis Issues Using R

I am using the R package sentimentr and sentiment function to get polarity/sentiment scores on a list of comments. The issue I am having is that the comments are in ...
0
votes
0answers
14 views

Ancova for unequal variances [duplicate]

What is the best way to compare two non-homogeinous populations (Levene's) with covariates (e.g. age). I know ancova assumes homogeneity. Is there a way around this? Many thanks
2
votes
1answer
53 views

How to code random slopes random intercept model with quadratic term and covariance unstructured in lme4

I've worked through quite some documentation about both the nlme and lme4 package, (and quite some fora) but am still unsure whether I'm doing the right thing. Here's what I want to do: I want to ...
0
votes
0answers
13 views

Cluster analysis with one attribute

I have a dataset of products and the price of each product. I want to perform clustering to group products of similar prices together. Would k-means clustering be appropriate? Is scaling of variables ...
1
vote
1answer
44 views

Running a mixed effects model in R with lmer()

I am currently trying to run a mixed effect model in R for a study I am conducting. I am looking at the effect of target ethnicity on objectification and whether affinity mediates this relationship. ...
1
vote
1answer
54 views

OLS estimation of intercept in AR($p$) in R

I investigate the performance of the OLS estimator of an AR($3$) model given by $$ X_t=\mu+\phi_1X_{t-1}+\phi_2X_{t-2}+\phi_3X_{t-3}+\varepsilon_t $$ for $t\in\mathbb Z$ using the following code: <...
0
votes
1answer
51 views

Time series with multiple variables and different start date

I have a dataset where sales values of multiple products are available. Some products have data starting from Jan 2014, but some products have data starting later than that and its varying for various ...
5
votes
3answers
152 views

Estimate $\lambda$ in the fitting line $x^\lambda$, where $x \in [0, 1]$

Problem I would like to estimate $\lambda$ in the fitted line $x^\lambda$, where $x \in [0, 1]$. Note that the following R code generates "concave" growth as x ...
1
vote
0answers
12 views

Two groups but repeated measures across time only for one

I am confuse to find what model do I use. I have two group (A, B) with treatment, A has a treatment in t=0 only, but B has treatment in t=0 , 10 and 20. is-it possible to make one big model (ANOVA; ...
2
votes
1answer
55 views

glm.fit: fitted probabilities numerically 0 or 1 occurred however culprit feature is numeric

I've been receiving the warning message in the title and have reviewed posts such as e.g. this one. I would like to understand how this feature has perfect separation with the target variable, since ...
0
votes
0answers
28 views

r - Why does rlm (MASS package) return a model without intercept? [migrated]

Test code: rlm(x=runif(100, 100, 200), y=runif(100, 10000, 10002)) lm(runif(100, 10000, 10002)~runif(100, 100, 200)) Result of lm() is sensible: ...
2
votes
0answers
21 views

Cholesky Decomposition (in lmer from lme4)

When I retrace the implementation of lmer from lme4 I faced a question regarding cholesky decomposition used for solving penalized least squares. Consider a Cholesky decomposition of a matrix M with ...
0
votes
0answers
22 views

Effect size in Negative Binomial Mixed Model

Is there a way to calculate Cohen's d (effect size) equivalent for a coefficient in level 1 (i.e., fixed effect) based on the output from a negative binomial mixed model (...
0
votes
0answers
9 views

how to calculate afterwards and backwards average of panel data in R?

How to calculate and in unbalanced panel data? I try to use function() and ddply(), but I don't know how to define the range(starts from the first period and ends at period t-1 and vice versa). ...
0
votes
0answers
5 views

Bi-modal coefficient estimates of bootstrapped difference in differences estimate

I'm trying to conduct a sanity check on a really strange result I'm finding. I specified the following difference in differences logistic model in R: $Pass = \beta_{0} + \beta_{1}Attended\times\...
1
vote
1answer
41 views

Modelling binomial outcome in repeated measures design using glmer

I have a complex dataset for a repeated measures design. Each participant (N=53) saw a total of 72 images that varied according to three different properties (2 categorical and 1 ordinal independent ...
1
vote
0answers
25 views

Understanding Lenth Plot in R

I would like to understand how to interpret the Lenth Plot. From what I know from the LenthPlot R page, this plot displays the factor effects with significance levels. But I don't really get what a ...
0
votes
1answer
29 views

How to test the significant of multiply chi square tests

I know that if I have a model from which I have a very large sample, so that I can create a null distribution. And I also have an experimental sample, I can use the ChiSquare test (or FisherExact test)...
0
votes
0answers
9 views

Getting Significance Information from glm object

I am creating 1000 logistic models in R with glm(), using a different 75% of my data each time. Currently, I am doing this via for-loop (which I have been told is ...
0
votes
0answers
19 views

Permutation tests for paired data with several variables

I am trying to answer my own previous question, with a permutation method. I have a reference method $M_{ref}$ that I would like to compare with other methods $M_1$, $M_2$, $M_3$ when taking ...
0
votes
0answers
27 views

Likelihood of an event to belong to a certain cluster in R

This is a follow up on another question I have while working on this same dataset (:datanet). Here's a sample of the data: ...
0
votes
1answer
47 views

Simulate data based on negative binomial regression coefficient

I'm trying to simulate a dataframe with columns x and y based on a real-world dataset. Fitting a negative binomial regression ...
0
votes
0answers
6 views

parameter boundary in LaplacesDemon (R library)

In LaplacesDemon (R library), I was wondering if there is a way to restrict the samples to come from a certain range. The model is set to have a prior calculated, but I don't think it is being ...
0
votes
0answers
20 views

Comparing one group with others when repeated measures with non-parametric tests corrected for multiple comparison

I have a reference method $M_{ref}$ that I would like to compare with other methods $M_1$, $M_2$, $M_3$ when taking measurements (denoted scores from now on) from a data sample of size $N (N > 30)$....
0
votes
1answer
29 views

difference between interaction with anova and contrast functions

I'm trying to understand the difference between the interaction with the anova function and the interaction with the contrast ...
1
vote
1answer
63 views

R: generalised additive model on proportional data

Introduction I am analysing temporal population data on the amphipod Orchestia gammarellus. At several moments each year, all animals were collected from a small spot, and several life history traits ...
1
vote
0answers
15 views

R daisy - Gower distance, different values with different number of observations [duplicate]

I have a mixed data set where I want to compute distances between observations with Gower in R (daisy function). When I compute distances between different number of observations, the distances seem ...
0
votes
1answer
26 views

Model differences of differences

We want to model how a continuous variable (A) vary (slope) in two different conditions (categorical variable B) accross another categorical variable (C) to answer the question. Does the metric used (...
1
vote
1answer
82 views

Find (or calculate) log-likelihood value, AIC, and BIC for SUR model (for each equation) with systemfit

I have estimated SUR model with systemfit (R package). With the estimated results, I am trying to get logLik, AIC and BIC for ...
5
votes
1answer
96 views

How to improve this time series model?

I am trying to fit a time series model for household data which is a time series variable. Initially my data looks like this, Since the data does not seem to be stationary I differenced the data. ...
0
votes
0answers
11 views

R - Aggregating weights from multiple categorical variables

I used the lm function to fit a linear model on my data. Some of my data are multi-levels categorical variables (say season : summer, autumn, winter, spring). The lm function automatically splitted ...
0
votes
0answers
10 views

Error in lm.circlular.cl

I have a dataframe where I have information on the departure bearing when individuals are leaving a certain site, the departure date, and the distance they travelled. I'm interested in modelling the ...
5
votes
0answers
34 views

Compare if two regression model behaves similarly

this is my first asking question here... forgive me if my question is not clear enough. I have two datasets; one is ground truth dataset and another is perturbed version of the same dataset. I want ...
0
votes
1answer
16 views

Fitting a linear model using lm and a variable as factor [closed]

I am new to R and I'm confused by lin_mod <- lm(temp~as.factor(activ), data=beav2) specifically as.factor(activ). Why do ...
1
vote
0answers
14 views

Comparing 3 raster maps of continuous surface data in R

I have 3 maps representing spatial distribution in hunting pressure. These maps were derived using different methods and I am now interested in comparing them to assess how they might differ/agree ...
2
votes
0answers
69 views

Difference between s() and ti() terms in mgcv package when applied to one variable

I am using the mgcv package in R to fit logistic GAMs to survey data. In one of my models I use an interaction between two covariates. I am currently trying to fit ...
0
votes
1answer
31 views

Transfering the approach of GLM/GLM.NB to FEGLM in R to find the best dispersion parameter

I would like to analyze my dataset with around 1 million observations and 10 thousand fixed effects with a negative binomial regression model. Due to the high number of fixed effects I cannot apply '...
0
votes
1answer
12 views

Calculating normality for a two way ANOVA with repeated measures

I am trying to calculate if my residuals are normally distributed for my two way ANOVA with repeated measures on Rstudio. However, all the tutorials I find seem to specific to one way within ANOVAs ...
0
votes
1answer
21 views

Evaluate Sample Representativeness of Dataset

I'm trying to check / evaluate how representative a sample is from a dataset. I'm interested in two things: Which sample best represents the original dataset Is the sample a "good enough" ...
3
votes
1answer
74 views

predict.bsts does not capture holiday information

EDIT (Tue12Mar): The bug fixes are on their way. See https://github.com/steve-the-bayesian/BOOM/issues/25 I've been working with bsts to model time-series and make forecasts, but have run into some ...
0
votes
0answers
10 views

Would this be a correct way to sample from intuitively correlated variables?

I have three variables and each represent some metric of people and can have values within different ranges e.g. ...
0
votes
0answers
9 views

prop.test alternative usage for differences test

I have a following matrix mat of successes: 50 24 46 36 and want to perform a 2-sample test for equality significance with <...
0
votes
0answers
13 views

Dimension Reduction for mixed variables

I am working with a dataset which consists of both categorical (14 vars) and continuous variables (5). Each categorical variable consists of a minimum of 2 categories up to 106 categories. The aim ...
0
votes
0answers
7 views

Maximum Likelihood estimation with bbmle

My question concerns the table on page 84 and the maximum likelihood estimation code on page 96 of the document http://www.scienpress.com/Upload/TMA/Vol%205_1_5.pdf. Specifically, how did the author ...
0
votes
0answers
13 views

How to interpret regression coefficients when each predictor variable contains different categories

Overview: I have conducted two types of statistical analysis using both linear regression and multiple regression. Overall, there were two observation periods, and the idea is to gauge if the rate ...
0
votes
0answers
7 views

nested logit: must all nests contain at least 2 items?

I'm estimating a model about how people travel in R. There are 4 alternatives: air, car, bus, and train. I want to create a nested logit model in which travelers first choose whether or not to fly, ...
0
votes
0answers
31 views

Acceptable CFI but poor TLI

I'm working on a path analysis using lavaan in R. Here is my model fit result: Chi square: >.05 Confirmatory Fit Index (CFI): 0.94 Tucker Lewis Index (TLI): 0.86 Root Mean Square Error of ...
0
votes
0answers
9 views

MLE of an EGARCH(1,1) Model with Gaussian Innovations

I want to estimate parameters of an exponential GARCH(1,1); namely EGARCH(1,1) model using optimization tools at R. However, I don't want to use a ready package like rugarch or an another package. I ...
2
votes
0answers
35 views

Sum of Random Variables — An Example with R [closed]

So I was trying to simulate these formulas from my lecture with R. $$E[\bar{X_n}] = \mu_x\text{, where $X_i \sim i.i.d$}\\Var(\bar{X_n}) = \frac{1}{n}*\sigma^2_x$$ My code in R: ...