Using R to run multilevel models

I'm learning how to run multilevel models in R.

I tried the analysis of variance model, AKA, the intercept-only model.

fit<lme(post_test~1,random=~1|school,data=mySASData,control=list(opt="optim"))
summary(fit)
anova(fit)
VarCorr(fit)
summary(fit)

 

I run this in SAS and get the same results.  I didn't get the same degree of freedom.

proc glimmix data=sashlm.core_2014_4_years;
class school;
model post_test=/solution ddfm=kr dist=normal link=identity;
random intercept /subject=school;
run;

Quotmarks Replacer: WordPress APP that fixes quotations

If I directly copy the R statement from the Internet and paste it into my R editor window, quotation marks may create errors.  This is the error I got.

setwd(“C:/”)
Error: unexpected input in "setwd(“"

Notice it involves “ and ”.  They look aesthetically pleasing as the first one clearly indicate the beginning quote and the second one the quotation end.  R and other software programs do not understand them.  I have to replace them with " for both.

To avoid this on the WordPress site, the following plug-in Quotmarks Replacer by  Tunghsiao Liu  is useful.

I installed it and activated it, so if you copy the following, it should run on R on your machine without a problem.

setwd("C:/temp")

Note: I am not exactly  sure if it is working right now. I activated it, but I don't see any way to specify options.  Maybe just activating it works, but still when I pasted this here:

setwd(“C:/”)

It still looks like it is using the old quotation  marks.

I used to use this long time ago and it used to work well.

 

 

.htaccess file

.htaccess file sits at the root directory of a webhosting folder.  You can modify this file to implement some security measures.  In my case, I needed to use FileZila to be able to see it, download it, and upload the modified version of it.  How to configure FileZilla was a major pain (see my article on Filezilla --> https://www.estat.us/file-zilla/ ).

This below prevents Chrome browser to indicate that your website is not secure.  This turns the web URL to begin with https (with S at the end) instead of just http and I believe S means extra security.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You also want to prevent visitors to see the contents of a subfolder.

# Disable directory browsing
Options All -Indexes

 

Reference:

https://help.dreamhost.com/hc/en-us/articles/215747758-Force-your-site-to-load-securely-with-an-htaccess-file

 

 

 

My first PHP program: Odds ratio and Cox index calculator

Finally ... at the age of 50 (!) ...  I was able to write my first PHP program.

http://www.estat.us/file/calc.php

 

Based on the results of logistic regression model (the intercept and the program impact estimate -- all expressed in logit), this program allows a user to calculate an odds ratio statistic and a standardized effect size (Cox index).  The algorithm can be found in What Works Clearinghouse's standard document:

WWC procedures handbook (see page. 14)
WWC standards slides (Definition of small sample size correction, slide 14)

I replied on the following materials:

Udemy, Reece Kenny's Create a REAL Social Network like Facebook in PHP + MySQL.  Honestly I didn't complete this course, but I learned how to run PHP and MySQL on my PC by installing XAMPP and running files from the XAMPP's subfolder (C:\xampp\htdocs).  I also would have never figured out how to look at results by opening the file from localhost (e.g., http://localhost/calc.php).

Michiko's code.  I first copied her simple calculator example and modified it to make my program.

 

How to run PHP on PC using XAMPP

Using an editor (Sublime Text), create a php file and place it in the designated folder:

C:\xampp\htdocs

In it I created a php file "progate_practice.php"with the following content. XAMPP's Apache must be on (I usually  click on both Apache and MySQL).

Use a browser and type in "http://localhost/progate_practice.php."  You will see the php result returned.   I have a subfolder I created for this purpose "C:\xampp\htdocs\kaz," but I couldn't let it run from there (I don't know why this does not work).

<?php
$menus = array(
array('name' => 'CURRY', 'price' => 9),
array('name' => 'PASTA', 'price' => 12),
array('name' => 'COFFEE', 'price' => 6)
);

$totalPrice = 0; // Variable to store the total price
foreach ($menus as $menu) {
$price = $menu['price'];
echo $menu['name'].' is $'.$price;
echo '<br>';
// Add each price to $totalPrice
$totalPrice += $price;
}
echo 'The total price is $'.$totalPrice;

?>

LearnDash

[ld_profile]

Displays user's enrolled courses, course progress, quiz scores, and achieved certificates. This shortcode can take following parameters:

  • order: sets order of courses. Default value DESC. Possible values: DESCASC. Example: [ld_profile order="ASC"] shows courses in ascending order.
  • orderby: sets what the list of ordered by. Default value ID. Possible values: IDtitle. Example: [ld_profile orderby="title" order="ASC"] shows courses in ascending order by title.

See the full list of available orderby options here.

 

[ld_course_list]

This shortcode shows list of courses. You can use this shortcode on any page if you dont want to use the default /courses page. This shortcode can take following parameters:

  • num: limits the number of courses displayed. Example: [ld_course_list num="10"] shows 10 courses.
  • order: sets order of courses. Possible values: DESCASC. Example: [ld_course_list order="ASC"] shows courses in ascending order.
  • orderby: sets what the list of ordered by. Example: [ld_course_list order="ASC" orderby="title"] shows courses in ascending order by title.
  • mycourses: show current user's courses. Example: [ld_course_list mycourses="true"] shows courses the current user has access to.
  • col: number of columns to show when using course grid addon. Example: [ld_course_list col="2"] shows 2 columns.
  • course_cat: shows courses with mentioned course category id. Example: [ld_course_list course_cat="10"] shows courses having course category with category id 10.
  • course_category_name: shows courses with mentioned course category slug. Example: [ld_course_list course_category_name="math"] shows courses having course category slug math.
  • course_categoryselector: shows a category dropdown. Example: [ld_course_list course_categoryselector="true"].
  • course_tag: shows courses with mentioned course tag. Example: [ld_course_list course_tag="math"] shows courses having course tag math.
  • course_tag_id: shows courses with mentioned course_tag_id. Example: [ld_course_list course_tag_id="30"] shows courses having course tag with tag_id 30.

See the full list of Category and Tag filtering options.

 

[ld_lesson_list]

This shortcode shows list of lessons. You can use this shortcode on any page. This shortcode can take following parameters: num, order, orderby, tag, tag_id, cat, category_name lesson_tag, lesson_tag_id, lesson_cat, lesson_category_name, lesson_categoryselector. See [ld_course_list] above details on using the shortcode parameters.

 

[ld_topic_list]

This shortcode shows list of topics. You can use this shortcode on any page. This shortcode can take following parameters: num, order, orderby, tag, tag_id, cat, category_name, topic_tag, topic_tag_id, topic_cat, topic_category_name, topic_categoryselector. See [ld_course_list] above details on using the shortcode parameters.

 

[ld_quiz_list]

This shortcode shows list of quizzes. You can use this shortcode on any page. This shortcode can take following parameters: num, order, orderby. See [ld_course_list] above details on using the shortcode parameters.

 

[learndash_course_progress]

This shortcode displays users progress bar for the course in any course/lesson/quiz pages.

 

[visitor]

This shortcode shows the content if the user is not enrolled in the course. The shortcode can be used on any page or widget area. This shortcode can take following parameters:

  • course_id: Optional. Show content if the student does not have access to a specific course. Example: [visitor course_id="10"]insert any content[/visitor]

 

[student]

This shortcode shows the content if the user is enrolled in the course. The shortcode can be used on any page or widget area. This shortcode can take following parameters:

  • course_id: Optional. Show content if the student has access to a specific course. Example: [student course_id="10"]insert any content[/student]

 

[course_complete]

This shortcode shows the content if the user has completed the course. The shortcode can be used on any page or widget area. This shortcode can take following parameters:

  • course_id: Optional. Show content if the student has access to a specific course. Example: [course_complete course_id="10"]insert any content[/course_complete]
  • user_id: Optional. If not provided will use current logged in user. Example: [course_complete course_id="10" user_id="456"]insert any content[/course_complete]

 

[course_inprogress]

This shortcode shows the content if the user has started but not completed the course. The shortcode can be used on any page or widget area. This shortcode can take following parameters:

  • course_id: Optional. Show content if the student has access to a specific course. Example: [course_inprogress course_id="10"]insert any content[/course_inprogress]
  • user_id: Optional. If not provided will use current logged in user. Example: [course_inprogress course_id="10" user_id="456"]insert any content[/course_inprogress]

 

[course_notstarted]

This shortcode shows the content if the user has access to the course but not yet started. The shortcode can be used on any page or widget area. This shortcode can take following parameters:

  • course_id: Optional. Show content if the student has access to a specific course. Example: [course_notstarted course_id="10"]insert any content[/course_notstarted]
  • user_id: Optional. If not provided will use current logged in user. Example: [course_notstarted course_id="10" user_id="456"]insert any content[/course_notstarted]

 

[ld_course_info]

This shortcode shows the courses for the user. This shortcode can take following parameters: user_id if not provided will assume current user. Example usage: [ld_course_info user_id="123"] will show the courses for the user 123

 

[ld_user_course_points]

This shortcode shows the earned course points for the user. This shortcode can take following parameters: user_id if not provided will assume current user. Example usage: [ld_user_course_points]

 

[user_groups]

This shortcode displays the list of groups users are assigned to as users or leaders.

 

[ld_group]

This shortcode shows the content if the user is enrolled in a specific group. Example usage: [ld_group]Welcome to the Group![/ld_group] This shortcode takes the following parameters:

  • group_id: Required. Show content if the student has access to a specific group. Example: [ld_group group_id="16"]insert any content[/ld_group]

 

[ld_video]

This shortcode is used on Lessons and Topics where Video Progression is enabled. The video player will be added above the content. This shortcode allows positioning the player elsewhere within the content. This shortcode does not take any parameters.

 

[learndash_payment_buttons]

This shortcode can show the payment buttons on any page. Example: [learndash_payment_buttons course_id="123"] shows the payment buttons for course with Courses ID: 123

 

[course_content]

This shortcode displays the Course Content table (lessons, topics, and quizzes) when inserted on a page or post. Example: [course_content course_id="123"] shows the course content for course with Course ID: 123

 

[ld_course_expire_status]

This shortcode displays the user course access expire date. Example: [ld_course_expire_status course_id="111" user="222" label_before="Course access will expire on:" label_after="Course access expired on:" format="F j, Y g:i a"].

  • course_id: The ID of the Course to check. If not provided will attempt to user current post. Example: [ld_course_expire_status course_id="111"]
  • user_id: The ID of the user to check. If not provided the current logged in user ID will be used. Example: [ld_course_expire_status user_id="222"]
  • label_before: The label prefix shown before the access expires. Default label is "Course access will expire on:" Example: [ld_course_expire_status label_before="Your access to this course will expire on:"]
  • label_after: The label prefix shown after access has expired. Default label is "Course access expired on:" Example: [ld_course_expire_status label_after="Your access to this course expired on:"]
  • format: The controls the format of the date/time value shown to the user. If not provided the date/time format from your WordPress sytem will be used. Example: [ld_course_expire_status format="F j, Y g:i a"]