Skip to content

Instantly share code, notes, and snippets.

View 13bzhang's full-sized avatar

Baobao Zhang 13bzhang

View GitHub Profile
@13bzhang
13bzhang / qualtrics_text_textbox.js
Created April 8, 2016 01:51
Qualtrics text before and after textbox
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place Your Javascript Below This Line*/
var inputs = $(this.getQuestionContainer()).select('input[type="text"]');
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
$(input).insert({before: 'In '});
$(input).insert({after: ' years'});
@13bzhang
13bzhang / predict_lm.R
Last active February 11, 2020 00:49
Prediction function for linear regression with robust/cluster robust standard errors
predict.lm <- function(mod, predict.df, rob, cluster = NULL){
##Written by Joshua Gubler ~ http://scholar.byu.edu/jgubler
##Last updated on 26 June 2014
##Updated by Baobao Zhang
##This provides an option for robust (including cluster robust) or non-robust standard errors
##Note: when estimating a polynomial, you must create the quadratic/cubic as a separate variable first!! This is also the best procedure when estimating logged effects. However, when estimating interaction effects, there is no need to create a separate interaction term.
##Also note, that for this function to work well, you must input factor variables with more than two levels individually (as indiviual dummies).
if(missing(predict.df)){ predict1.df <- mod$model }
@13bzhang
13bzhang / qualtrics_autofill.html
Last active June 25, 2017 19:03
Qualtrics autofill
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>