Week 3: Hypothesis Testing and Significance Flashcards

1
Q

What command generates a new variable?

A

<gen>
</gen>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you recode continuous variables into categorical variables?

A

Use the <recode> or <replace> command in combination with <if> statements to specify ranges and assign categories.
Example:
recode varname (a/b=1) (c/d=2) (e/f=3), gen(newvarname)</if></replace></recode>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which command labels a variable?

A

<label variable varname “name”>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you ensure the correct categories after recoding a variable?

A

Use frequency tables and crosstabs, such as <tab></tab>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax to assign value labels to a variable?

A

<label define labelname value1”label1” value2”label2”, replace>
<label></label>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the <egen> command do?</egen>

A

Creates derived variables, such as sums or counts, across specified variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of <foreach> and <forvalues> loops?</forvalues></foreach>

A

They automate repetitive tasks, such as recoding multiple variables

<foreach> is a more general loop that allows string, numeric, and variables as list (without a pattern).
<forvalues> is a more specific loop. Only numeric is allowed as lists, and lists should have a clear pattern.
</forvalues></foreach>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How are missing values assigned in a new variable during coding?

A

Use <replace varname =. if condition>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you combine two categorical variables into one?

A

Use a combination of logical operators (I, &) and <recode> or <gen> to conditionally create a new variable.
Example:
<gen newvar=.>
<replace newvar=0 if var1==a | var2==b></gen></recode>

<replace> b & var2==c>
etc...
<label variable newvar "Variable name">
<label define newvar1 0"abcd" 1"efgh">
<label>
</label></replace>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the syntax to count specific values across multiple variables?

A

<egen newvar = anycount(varlist), values(value)>
Example: To count number of those with asthma
<egen asthma = anycount (hedib01-hedib06), values(2)>
Here, we know that (2) denotes the presence of asthma in the initial variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you compute the sum of multiple variables into a single variable?

A

Use <egen newvar = rowtotal(varlist)>
Example:
<egen tot_heart_sum = rowtotal(heart_*)>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What command is used to produce a frequency table?

A

<tab>
</tab>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does reverse coding ensure in survey data?

A

It aligns differently phrased questions for consistent interpretation in scales or indices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you check for errors after creating a new variable?

A

Cross-tabulate the new variable with its original counterpart and examine discrepancies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the <rowtotal> function in <egen> calculate?</egen></rowtotal>

A

The sum of specified variables across a row for each observation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a “derived variable”?

A

A variable created from existing data, often through transformations or aggregations.

17
Q

How can you handle negative or missing values during recoding?

A

Use conditional statements like <replace varname =. if varname <0>

18
Q

What does the command <label> do?</label>

A

It creates a set of value labels that can be assigned to variables

19
Q

Why is it good practice to verify recoding with cross tabs?

A

Ensure all values have been correctly categorised

20
Q

What is the first step to take in deriving a new variable?

A

Create a new ‘empty’ variable using the command <gen varname =.>

21
Q

How do you delete a variable if you made a mistake in recoding?

A

<drop>
</drop>

22
Q

How would you calculate the mean of a continuous variable sorted by a categorical variable?

A

<mean contvar, over(catvar)>
Note: You can also use logical operators e.g., mean <varname if cond1==2 | cond2==3>

23
Q

What character do you use to capture all variables that start with the same letters?

A

Example: If you want to capture all variables starting with hedia <hedia*>

24
Q

How can you create a single variable showing the number of heart conditions a respondent has in the ELSA dataset? (hedia0-7)

A

To count the number of conditions a respondent has, we need to recode the seven hedia variables into seven new variable, each denoting the presence or absence of a heart condition of any type. The scores will be 1 for any heart condition and 0 for no heart condition.
Command:
<recode hedia01 (96=0) (1/8=1), gen(heart01)>
<recode hedia01 (96=0) (1/8=1), gen(heart02)>
etc…

25
Q

How can you create a single variable showing the number of heart conditions a respondent has in the ELSA dataset? (hedia0-7) - using loops

A

<forvalues j=1/7{
recode hedia0j' (96=0) (1/8-1) (95=1) (min/-1=.), gen heart_j’)

26
Q
A