How to implement ivprobit in panel data in R? - binary

I know ivprobit function can be implemented well in cross-sectional data, and I see we can use cluster() command if we have panel data in Stata. However, what can I do in R in this case?

Related

How do I use Nodejs for backend using SQL workbench?

I am a beginner and this is my first full-stack web development project and I have completed the front-end part and created the related tables using MySQL... and now I want to link the tables to front-end using nodejs. How do I proceed further?? Is it proper to use workbench in the first place for a full-stack project?? Please guide me.
SQL Workbench is just an IDE for mySQL so thats fine for building out your DB, setting permissions etc.
Your question is not one that is simple to answer, simply because the steps in creating, setting up a full web app is not that simple to explain..
There are few things you will need to do to hook this up
Ensure you have a mySQL middleware installed
Ensure you have the routes created
Use a templating engine like EJS
Once you have the basic flow working ( meaning you can hit your page and it returns the correct page ) you will want to then hook into the DB before sending the response object back to the browser. A typical flow would be, on your 'get' response, you would perform the mysql 'select'
This should be promis based but will depend on the actual package you install, I don't use mysql but a postgres command is something like
query.pool("SELECT is, name, des from table where id = '10' ").then(results => {
//put in your response code here to send back to the page
}).catch( e => {console.error(e)})
The response code portion is where you would send things back to the page, in an ejs template would then be able to access the response and display the data.
I know, this is a bit light on full explanations and that is because the proper response would be huge!
Judging by the question I would guess you are a bit new to node / DB etc ( sorry if you are not ) I think what may be very helpful is to watch a few youtube videos on setting up Node and EJS ( or any templating engine for that matter )
That should give you the basic understanding and setup of the project.

How to generate a JSON file using JMeter Report Generator

I am trying to create a statistics.json file with JMeter using ReportGenerator, populated with the results of my .jmx tests. Is it possible to do this with JMeter?
I have gone through this tutorial: https://jmeter.apache.org/usermanual/generating-dashboard.html which focuses on creating an html dashboard using the Report Generator, but I have a project requirement of creating/updating a statstics.json file as well. I have already pulled the necessary data using a JSON Extractor post processor, and I can get the custom variables from that extractor to show up in my debug response, and in my CSV file (after adding some sample_variables to user.properties). Unfortunately I have been unsuccessful in finding more info about how to create a JSON file with these responses.
In my reportgenerator.properties file, the only parts I see that relate to json are:
jmeter.reportgenerator.exporter.json.classname=org.apache.jmeter.report.dashboard.JsonExporter
jmeter.reportgenerator.exporter.json.property.output_dir=report-output
I'm looking for some settings that would allow me to edit what goes into that JSON file, but I'm having trouble finding information in the docs. Do I need to be sending or setting my custom variables in another settings file? Any help clarifying this would be much appreciated!
Looking at JMeter source code you cannot efficiently control what's being exported into statistics.json file externally, you will have to either amend the JsonExporter class code or come up with your own implementation of the AbstractDataExporter and choose what, where and how to store.
private void createStatistic(Map<String, SamplingStatistic> statistics, MapResultData resultData) {
LOGGER.debug("Creating statistics for result data:{}", resultData);
SamplingStatistic statistic = new SamplingStatistic();
ListResultData listResultData = (ListResultData) resultData.getResult("data");
statistic.setTransaction((String) ((ValueResultData)listResultData.get(0)).getValue());
statistic.setSampleCount((Long) ((ValueResultData)listResultData.get(1)).getValue());
statistic.setErrorCount((Long) ((ValueResultData)listResultData.get(2)).getValue());
statistic.setErrorPct(((Double) ((ValueResultData)listResultData.get(3)).getValue()).floatValue());
statistic.setMeanResTime((Double) ((ValueResultData)listResultData.get(4)).getValue());
statistic.setMinResTime((Long) ((ValueResultData)listResultData.get(5)).getValue());
statistic.setMaxResTime((Long) ((ValueResultData)listResultData.get(6)).getValue());
statistic.setMedianResTime((Double) ((ValueResultData)listResultData.get(7)).getValue());
statistic.setPct1ResTime((Double) ((ValueResultData)listResultData.get(8)).getValue());
statistic.setPct2ResTime((Double) ((ValueResultData)listResultData.get(9)).getValue());
statistic.setPct3ResTime((Double) ((ValueResultData)listResultData.get(10)).getValue());
statistic.setThroughput((Double) ((ValueResultData)listResultData.get(11)).getValue());
statistic.setReceivedKBytesPerSec((Double) ((ValueResultData)listResultData.get(12)).getValue());
statistic.setSentKBytesPerSec((Double) ((ValueResultData)listResultData.get(13)).getValue());
statistics.put(statistic.getTransaction(), statistic);
}
An easier option would be writing your sample variables into a separate file using Flexible File Writer
I'm leaving the accepted answer because it is correct. However, I'd like to add that I was able to complete my requirement by using a JSR223 post processor to write a groovy script that creates a csv file wherever I need, and fill it with any data that I needed.

Reading from a text file into HTML

I want to make a small html based game for a school project. I would like to be able to extract data from a text file, then insert if necessary in order to save data. So my question is:
What programming language can i use in order to read from a .txt file into a HTML page?
Thanks in advance for any help you are able to provide.
My suggestion would be php. There are dozens of methods to achieve this. Note, however, that this task will be much easier to accomplish if your text file is on the same domain as the code. This is best for single levels that dont change.
Php
In php, you could use
$file = fopen('pathtofile.txt', r);
Note that the second parameter, r, signifies that the file should be readable. Use w if you want to write to the file.
There are a lot of tutorials on google for this.
Ajax
If you'd prefer not to use php, Ajax is also available to you via javascript. This method is best if you need to change files while the game is running, ie loading new levels.
$.ajax({
method: 'get',
path: 'pathtofile.txt',
success: function(data){
//level info is in **data**
},
error: function(x, h, r){
// this will display error info, ie file does not exist
}
})
The code above most likely won't work, it is intended as a demo. Again, there are plenty of examples for this on google.
Have fun and happy coding.

how to pass data from python to an HTML page

I am currently working on a program in python which keeps trak of a lot of builds.
This progress is reported in a html file which is current deleted and written again with the new data for me to update it. However I know this is not the idea approach though i have never really worked with html web pages in any degree what so ever.
But i would like to make it the right way but every time i search on something i just get how to pass data from a html page into a program. So what i am asking for is some guide lines as to what I need to look for to achive this.
Also any suggestion as to how the right approach whould be. I just need to pass data from my running python program to a html page.
Ad if im lucky maybe someone posseses a very simple exsample. like just a python constant passed to a text box or what ever on a html page.
Regards
Ephreal
#!/usr/bin/python3
__author__ = 'Aidan'
from urllib import request
goog_url = 'http://real-chart.finance.yahoo.com/table.csv?s=GOOG&d=8&e=2&f=2014&g=d&a=2&b=27&c=2014&ignore=.csv'
def dl(csv_url, dest):
response = request.urlopen(csv_url)
csv_str = str(response.read())
lines = csv_str.split("\\n")
fx = open(dest, "w")
for line in lines:
fx.write(line + "\n")
fx.close()
dl(goog_url, 'a.csv')
This will take a file from the web band save it to a filename of your choice.

Having trouble binding JSON data to a mobile list in Adobe Flash builder

Hi, i have been having some problems using JSON data in flash builder lately and I was hoping someone could help me out here.
I have spent the past month working solidly on this issue, so I HAVE been looking around, HAVE been trying out everything I can find or think of. I am simply stuck.
I have been working on a flex mobile application for the Blackberry Playbook tablet with Adobe Flash Builder 4.6. It is a reddit app, designed to give users the main reddit feed, subreddits, search function, hopefully log in stuff etc. Of course I need the aid of the reddit API to access this information, of which the documentation can be found here: https://github.com/reddit/reddit/wiki/API/ The api uses either XML or JSON formatted data.
Now onto my problem- Like mentioned above, i want to display the reddit feed inside the app. I want to be able to use a item renderer to customize the data that is shown within each entry of the list.
One entry would consist of:
1) a thumbnail of the image in the post
2) The title of the post
3) a 'like/dislike' button, but this is unimportant at the moment.
Of course to start out, i placed a spark List component onto the design view. Then i configured a new HTTP data service using the Data/Services panel. I specified http://www.reddit.com/r/all.json for the url. I configured the return type, and the did a Test Operation. Everything connected just fine. All the data came through as normal. I will give you an idea of what the data comes back as so that you may understand my issue later on.
Test Operation Results (json data structure):
NoName1
data
after
before
children
[0]
data
media_embed
score
id
title
thumbnail
url
(etc etc...)
kind
[1]
data
media_embed
score
title
thumbnail
(etc etc...)
kind
[2] (array continues)
modhash
kind
As you can see, to get to the thumnail for example, you would have to go through data.children[].data.thumnail. When I tried to bind this data to the spark List component, I specified the data service to be from the one above. Then I specified the Data provider option to be Children[], as this value is typically set to the array. Now this is where the trouble begins. The final option, Label Field, only gave me one value to choose from: 'kind'. So as you can tell, it wasnt expecting the data to go any further nested. It stops at the two value just within each array item, which would be Data and Kind, though it only offers me Kind. I need to go one level further to access Title and Thumbnail. This is my problem.
Now, I have analyzed the code for the binding, and I have tried altering it to accomodate the further nested value. No success what so ever. The following is the code that the binding generates:
<s:List
id="myList" width="100%" height="100%" change="myList_changeHandler(event)"
creationComplete="myList_creationCompleteHandler(event)" labelField="kind">
<s:AsyncListViewlist="{TypeUtility.convertToCollectionredditFeedJSONResult.lastResult.data.children)}"/>
<s:List>
Obviously i would want to have something like along the lines of:
"TypeUtility.convertToCollection(redditFeedJSONResult.lastResult.data.children.data" and then set the labelField="title" or "thumbnail".
I certainly hope someone can help me with this. I am out of my mind as to what to do. If you need any further clarification I would be happy to provide it. I tried to explain the situation above as clearly as possible. Thank you so much.
Ted
I have this situation often: get an XML or JSON data from the server, then trying to use it as a dataProvider for a spark.components.List or for a mx.controls.Menu and then they just wouldn't display the data as I want them, because something in the data is different from what they expect. And then they display wrong XML-children or [Object,Object,etc.]
And in such cases I just create an empty ArrayCollection() which serves as dataProvider instead (and can be sorted and/or filtered too). And when data comes from the server, I push() new Objects into it:
[Bindable]
private var _data:ArrayCollection = new ArrayCollection();
public function update(xlist:XMLList):void {
_data.length = 0;
for each (var xml:XML in xlist)
_data.push({label: xml, event: xml.#event});
}
This always works. And if you get your next problem - flickering of the List, then that is solvable by merging data too.
Good luck with your Playbook development, which is a cool piece of hardware :-)