statistics

missing value where TRUE/FALSE needed in R [duplicate]

怎甘沉沦 提交于 2019-12-12 01:52:03
问题 This question already has answers here : Error in if/while (condition) {: missing Value where TRUE/FALSE needed (2 answers) Closed 4 years ago . When I run the following code without commenting gr.ascent(MMSE, 0.5, verbose=TRUE) I receive this error Error in b1 * x : 'b1' is missing but when I comment that line I receive the following error when testing MMSE with these arguments MMSE(2,1,farmland$farm,farmland$area) . Do you know where my problem is lying? Error in if (abs(t[i]) <= k) { :

Calculate Number of Occupied Days within a date period using MySQL and PHP

柔情痞子 提交于 2019-12-12 01:28:04
问题 I have an apartment booking system and need to generate a report of number of occcupied days vs. unoccupied days within a date period on a property by property basis. Bearing in mind within the chosen period that some bookings may start before and/or end after the start / end date respectivley. I found this - MySQL Number of Days inside a DateRange, inside a month (Booking Table) - which is along the right lines, but I don't want it on a fixed, month by month basis but rather between two

calibration of the posterior probabilities

梦想与她 提交于 2019-12-12 01:22:34
问题 currently i work on calibration of probability. i use the calibration approach, called rescaling algorithm - the source http://lem.cnrs.fr/Portals/2/actus/DP_201106.pdf (page 7). the algorithm i wrote is: rescaling_fun = function(x, y, z) { P_korg = z # yhat_test_prob$BAD P_k_C1 = sum(as.numeric(y) - 1)/length(y) # testset$BAD P_kt_C1 = sum(as.numeric(x) - 1)/length(x) # trainset$BAD P_k_C0 = sum(abs(as.numeric(y) - 2))/length(y) P_kt_C0 = sum(abs(as.numeric(x) - 2))/length(x) P_new <- ((P_k

Multiple curves with same Time x-axis in R

五迷三道 提交于 2019-12-12 01:07:20
问题 Could-you help me please in solving this issue. In fact, i would like to plot multiple curves on the same graph on R with a x-axis which is time labeled. I tried this : dayTime = strptime(sapply(c(0:110)+480, function(x){paste(floor(x/60),":",x%%60, sep="")}), "%H:%M") n = 10 pdf("myGraph.pdf") plot(x=dayTime, y=rep(0, length(dayTime)), main="myGraph", xlab="Time", ylab="Level", type="n", ylim=c(0, 0.05), xaxt = "n") for(i in 1:n) { lines(myData[, i]), col=i) } r = as.POSIXct(round(range

R Chi-squared stratified by multiple groups

霸气de小男生 提交于 2019-12-11 23:57:40
问题 I've the following df with 3 factors variables and one percentage variable: df <- data.frame( group = rep(c("Case", "Control"), each=16), timing = rep(c("T0", "T1", "T2", "T3"), each=4, times=2), food.type = rep (c("Very healthy", "Healthy", "Unhealthy", "Very bad"), times = 8), intake.percentage = runif(32, min=1, max=25) ) How do I perform the test (chi squared) in order to evaluate statistical difference each time (T0-T3) between groups (case; controls) for each kind of food? For your

php imagemagick statistics usage

烂漫一生 提交于 2019-12-11 20:07:02
问题 I'm trying to compute the average brightness of an image using Imagemagick's getImageChannelStatistics function. I will then use modulateImage to decrease the brightness if if reaches a given threshold. array Imagick::getImageChannelStatistics ( void ) 1st question: The returned mean value of each channel is greater than 255, although the color depth is 8. How to interpret these values ? Array ( [mean] => 27510.293108724 [minima] => 0 [maxima] => 65535 [standardDeviation] => 23761.909802897

outlier detection based on gaussian mixture model

主宰稳场 提交于 2019-12-11 19:35:24
问题 I have a set of data. I want to build a one class distribution from that data. Based on the learned distribution I want to get a probability value for each of the data instance. Based on this probability values (thresholding) I want to build a classifier to classify a particular data instance is comming from that distribution or not. In this case, lets say I have a data of 50x100000 where 50 is the dimension of each data instance, the number of instances are 100000. I am leaning a Gaussian

How to exclude certain observations while generating summary statistics without creating a new data frame in R

旧时模样 提交于 2019-12-11 19:33:22
问题 My problem is: I have a large number of numeric variables for which I need to generate summary statistics. Some of the observations are coded "-99", which means the participant does not know the answer to the survey question. While calculating means for such variables, I want to exclude the "-99" observations. Since I have a lot of variables, it would be quite onerous to use "subset". Does anyone know an easier way? PS: I know that for factors, the >- Summarize(df, exclude ="") command in the

How to extract a parameter from a list of functions in a loop

自闭症网瘾萝莉.ら 提交于 2019-12-11 19:25:16
问题 I have a large data set and I want to perform several functions at once and extract for each a parameter. The test dataset: testdf <- data.frame(vy = rnorm(60), vx = rnorm(60) , gvar = rep(c("a","b"), each=30)) I first definded a list of functions: require(fBasics) normfuns <- list(jarqueberaTest=jarqueberaTest, shapiroTest=shapiroTest, lillieTest=lillieTest) Then a function to perform the tests by the grouping variable mynormtest <- function(d) { norm_test <- res_reg <- list() for (i in c("a

Trying to understand the inverse transform method for generating a Poisson random variable

别来无恙 提交于 2019-12-11 18:24:04
问题 The algorithm Wikipedia gives for generating Poisson-distributed random variables using the inverse transform method is: init: Let x ← 0, p ← e^−λ, s ← p. Generate uniform random number u in [0,1]. while u > s do: x ← x + 1. p ← p * λ / x. s ← s + p. return x. I implemented it in R: f<-function(lambda) { x<-0 p<-exp(-lambda) s<-p u<-runif(1) while (u>s ) { x<-x+1 p<-p*lambda/x s<-s+p } return(x) } but I don't understand how this generates values of this random variable, and I also think the