r

lmer or binomial GLMM

China☆狼群 提交于 2021-02-11 06:48:11
问题 I am running a mixed model in R. However I am having some difficulty understanding the type of model I should be running for the data that I have. Let's call the dependant variable the number of early button presses in a computerised experiment. An experiment is made up of multiple trials. In each trial a participant has to press a button to react to a target appearing on a screen. However they may press the button too early and this is what is being measured as the outcome variable. So for

lmer or binomial GLMM

五迷三道 提交于 2021-02-11 06:48:09
问题 I am running a mixed model in R. However I am having some difficulty understanding the type of model I should be running for the data that I have. Let's call the dependant variable the number of early button presses in a computerised experiment. An experiment is made up of multiple trials. In each trial a participant has to press a button to react to a target appearing on a screen. However they may press the button too early and this is what is being measured as the outcome variable. So for

How can I specifically add .0 to integers in a column containing both integers and decimals?

六眼飞鱼酱① 提交于 2021-02-11 06:45:17
问题 Question: how can I specifically add .0 to all df$x -values not containing decimals? Take the following a dataframe df <- data.frame(x=c("2.8","9","0.5","1.2","4","12")) > head(df) x 1 2.8 2 9 3 0.5 4 1.2 5 4 6 12 The desired result looks like this > head(df) x 1 2.8 2 9.0 3 0.5 4 1.2 5 4.0 6 12.0 EDIT I want to automatically add .0 to all integers in ee$x , which is included below. I tried ee$x <- as.numeric(as.character(ee$x)) but that didn't seem to work. Could anything be wring with my

How can I specifically add .0 to integers in a column containing both integers and decimals?

回眸只為那壹抹淺笑 提交于 2021-02-11 06:43:59
问题 Question: how can I specifically add .0 to all df$x -values not containing decimals? Take the following a dataframe df <- data.frame(x=c("2.8","9","0.5","1.2","4","12")) > head(df) x 1 2.8 2 9 3 0.5 4 1.2 5 4 6 12 The desired result looks like this > head(df) x 1 2.8 2 9.0 3 0.5 4 1.2 5 4.0 6 12.0 EDIT I want to automatically add .0 to all integers in ee$x , which is included below. I tried ee$x <- as.numeric(as.character(ee$x)) but that didn't seem to work. Could anything be wring with my

New behavior in data.table? .N / something with `by` (calculate proportion)

南楼画角 提交于 2021-02-11 06:43:16
问题 I updated to the latest version of data.table - 1.9.4, from a medium-recent prior version (I think 1.8.X), and now I'm getting some unexpected behavior. set.seed(12312014) # a vector of letters a:e, each repeated between 1 and 10 times type <- unlist(mapply(rep, letters[1:5], round(runif(5, 1, 10), 0))) # a random vector of 3 categories category <- sample(c('small', 'med', 'large'), length(type), replace=T) my_dt <- data.table(type, category) Say I want the proportion of category by type. I

New behavior in data.table? .N / something with `by` (calculate proportion)

折月煮酒 提交于 2021-02-11 06:42:41
问题 I updated to the latest version of data.table - 1.9.4, from a medium-recent prior version (I think 1.8.X), and now I'm getting some unexpected behavior. set.seed(12312014) # a vector of letters a:e, each repeated between 1 and 10 times type <- unlist(mapply(rep, letters[1:5], round(runif(5, 1, 10), 0))) # a random vector of 3 categories category <- sample(c('small', 'med', 'large'), length(type), replace=T) my_dt <- data.table(type, category) Say I want the proportion of category by type. I

Creating a dataframe with text from a website

核能气质少年 提交于 2021-02-11 06:38:10
问题 I've been asked to create a data frame in R using information copied from a website; the data is not contained in a file. The full data list is at: https://www.npr.org/2012/12/07/166400760/hollywood-heights-the-ups-downs-and-in-betweens Here is a portion of the data: Leading Men (Average American male: 5 feet 9.5 inches) Dolph Lundgren — 6 feet 5 inches John Cleese — 6 feet 5 inches Michael Clarke Duncan — 6 feet 5 inches Vince Vaughn — 6 feet 5 inches Clint Eastwood — 6 feet 4 inches Jimmy

data.table calculate sums by two variables and add observations for “empty” groups

柔情痞子 提交于 2021-02-11 06:36:28
问题 Sorry for the bad title - I am trying to achieve the following: I have a data.table dt with two categorical variables "a" and "b". As you can see, a has 5 unique values and b has three. Now e.g. the combination of categorical variables ("a = 1" and "b = 3") is not in the data. library(data.table) set.seed(1) a <- sample(1:5, 10, replace = TRUE) b <- sample(1:3, 10, replace = TRUE) y <- rnorm(10) dt <- data.table(a = a, b = b, y = y) dt[order(a, b), .N, by = c("a", "b")] # a b N #1: 1 1 2 #2:

R-squared within for a regression with multiple fixed effects [closed]

筅森魡賤 提交于 2021-02-11 06:30:32
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 months ago . Improve this question I would like to get the R-squared within for a fixed effect regression with multiple fixed effects (let's say Country, Year, Trimester). The least squared dummy variable (LSDV) model ( lm in R/ reg in Stata) would only provide the overall R-squared. The same is

How to compute similarity in quanteda between documents for adjacent years only, within groups?

大兔子大兔子 提交于 2021-02-11 06:17:46
问题 I have a diachronic corpus with texts for different organizations, each for years 1969 to 2019. For each organization, I want to compare text for year 1969 and text for 1970, 1970 and 1971, etc. Texts for some years are missing. In other words, I have a corpus, cc, which I converted to a dfm Now I want to use textstat_simil : ncsimil <- textstat_simil(dfm.cc, y = NULL, selection = NULL, margin = "documents", method = "jaccard", min_simil = NULL) This compares every text with every other text,