Enable contrast version

# Tutor profile: Daniël v.

Inactive
Daniël v.
9 years experience -- Friendly and patient tutor with Ph.D in Statistics
Tutor Satisfaction Guarantee

## Questions

### Subject:R Programming

TutorMe
Question:

Let's say we want to fill a matrix structure with numbers. The matrix has 100 rows and 10 columns. We put in the numbers 1, 2, 3, ... 1000. So the matrix will look like this: [ 1] [ 2] [ 3] [ 4] ... ... ... ... ... ... ... ... ... ... Now, suppose you want to substract the row average from every number and store the result in a new variable. One way to do that is as follows: myData <- matrix(1:1000, ncol = 10) myDataModified <- myData for(i in 1:nrow(myData)) { myDataModified[i,] <- myData[i,] - mean(myData[i,]) } How can we achieve the same result using the apply function instead of a loop?

Inactive
Daniël v.

When we use the apply function, we must specify 3 arguments apply( [1}, ,  )  The object we are targeting  Whether we want to operate on the rows (1) or columns (2)  Which function we want to apply Now, if we simply want the row means, the specification is simpler: apply(myDataModified, 1, mean) However, we can also write a custom function which gives us much more flexibility: t(apply(myDataModified, 1, function(x) { x - mean(x) })) Note that 't()' is the transpose function. Without it, we would get a matrix back with 100 columns and 10 rows. The matrix would be on its side, so to say. So we fix that by transposing the matrix.

### Subject:Basic Math

TutorMe
Question:

If y = x^2 + 4, express x in terms of y. Hence: x = ?

Inactive
Daniël v.

1) Substract 4 from both sides: y - 4 = x^2 + 4 - 4 --> y - 4 = x^2 2) Take the square-root from both sides: sqrt(y-4) = sqrt(x^2) = x --> x = sqrt(y-4)

### Subject:Statistics

TutorMe
Question:

Typically, in hypothesis testing, researchers formulate a hypothesis and a sample is drawn from the population to either reject or maintain their nul hypothesis. An example of a nul hypothesis is: Male students and female students are equally old on average. An example of a alternative hypothesis is: Male students are older on average than female students. To test this nul hypothesis, a random sample is drawn with N = 102 students, 51 males and 51 females. The researchers find a mean difference of 0.4 years and a p-value of 0.12 What is the interpretation of a p-value?

Inactive
Daniël v.

1) If the nul hypothesis were true (Male students are on average as old as female students) and 2) this experiment of taking a sample of N = 102 students were to be repeated an infinite number of times 3) under exactly the same circumstances Then the probability of finding this exact result (mean difference of 0.4 years) OR more extreme (>.4 years), equals 0.12 The reasoning behind the p-value is that we reject a nul hypothesis if we draw a sample that is very unlikely given that the nul hypothesis is true. Typically, if the probability of a sample result is less than 5% (p < 0.05), then researchers reject the nul hypothesis and the alternative hypothesis is assumed to be true.

## Contact tutor

Send a message explaining your
needs and Daniël will reply soon.
Contact Daniël